Created
September 30, 2014 06:23
-
-
Save StephenKing/96ff33911a290857e773 to your computer and use it in GitHub Desktop.
Gerrit hook header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Compatible with Gerrit 2.5, order may change from version to version.. | |
To figure out the input, use | |
print_r($_SERVER['argv']); | |
$argv = array ( | |
0 => '/var/gerrit/review/hooks/patchset-created', | |
1 => '--change', | |
2 => 'I7511a12935a6eff29593c0c19c895c625a703ceb', | |
3 => '--is-draft', | |
4 => 'false', | |
5 => '--change-url', | |
6 => 'http://review.typo3.org/1307', | |
7 => '--project', | |
8 => 'FLOW3/Packages/SwiftMailer', | |
9 => '--branch', | |
10 => 'master', | |
11 => '--topic', | |
12 => '12345', | |
13 => '--uploader', | |
14 => 'Karsten Dambekalns ([email protected])', | |
15 => '--commit', | |
16 => 'd8074e04611b5c95ab788b39c9a505329c36964a', | |
17 => '--patchset', | |
18 => '1', | |
); | |
*/ | |
// parse parameters into sth. easier to access, namely into $args | |
$args = array(); | |
for ($i = 1; $i < $_SERVER['argc']; $i++) { | |
if (substr($_SERVER['argv'][$i], 0, 2) == '--') { | |
$optionName = substr($_SERVER['argv'][$i], 2); | |
$args[$optionName] = $_SERVER['argv'][$i + 1]; | |
$i++; | |
} else { | |
echo "Ignored unexpected parameter #" . $i . ": " . $_SERVER['argv'][$i]; | |
} | |
} | |
// log input parameters | |
$parametersGiven = array(); | |
foreach ($args as $key => $value) { | |
$parametersGiven[] = $key . ":" . $value; | |
} | |
echo "Executing hook file " . __FILE__ . " (" . implode(", ", $parametersGiven) . ")"; | |
unset($parametersGiven); | |
# continue here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment