Skip to content

Instantly share code, notes, and snippets.

@radmiraal
Created June 26, 2012 14:19
Show Gist options
  • Save radmiraal/2996041 to your computer and use it in GitHub Desktop.
Save radmiraal/2996041 to your computer and use it in GitHub Desktop.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_STRICT);
$project = getenv('GERRIT_PROJECT');
$path = dirname(__DIR__ . '../');
$submodules = shell_exec(sprintf("cd %s && git submodule foreach --recursive 'git config remote.origin.url | grep \"%s.git\" || :'", $path, $project));
$submodules = explode(chr(10), $submodules);
foreach ($submodules as $index => $submodule) {
if (substr($submodule, 0, 9) !== 'Entering ') {
$path = realpath(__DIR__ . '/../' . str_replace(array('Entering ', "'"), '', $submodules[$index - 1]));
}
}
$cherryPickCommand = sprintf('git fetch ssh://%s/%s %s && git cherry-pick FETCH_HEAD', getenv('GERRIT_HOST'), $project, getenv('GERRIT_REFSPEC'));
echo shell_exec(sprintf('cd %s && %s', $path, $cherryPickCommand));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment