com karma: Only the RM may push to closed branches: hooks/pre-receive

From: Date: Fri, 24 Jan 2014 16:16:43 +0000
Subject: com karma: Only the RM may push to closed branches: hooks/pre-receive
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-75782@lists.php.net to get a copy of this message
Commit: 3f147364cb7d60fed9a00c2d87bfc8cb1a43e478 Author: Johannes Schlüter <johannes@schlueters.de> Fri, 24 Jan 2014 17:16:43 +0100 Parents: 3f2060b2b660e7a002c82ede71ca2785bdb2280b Branches: master Link: http://git.php.net/?p=karma.git;a=commitdiff;h=3f147364cb7d60fed9a00c2d87bfc8cb1a43e478 Log: Only the RM may push to closed branches Changed paths: M hooks/pre-receive Diff: diff --git a/hooks/pre-receive b/hooks/pre-receive index d98e297..d856987 100755 --- a/hooks/pre-receive +++ b/hooks/pre-receive @@ -24,9 +24,15 @@ include 'Git/ReceiveHook.php'; include 'Git/PreReceiveHook.php'; $weKnowWhatWeAreDoing = ['dsp', 'johannes']; +// On restricted branches forced pushes are only possible by users listed in $weKnowWhatWeAreDoing $restrictedBranches = ['php-src.git' => ['refs/heads/PHP-5.4', 'refs/heads/PHP-5.3', 'refs/heads/PHP-5.5', 'refs/heads/PHP-5.6', 'refs/heads/master'], 'playground.git' => ['refs/heads/dsp']]; +// On closed branches only RMs may push +$closedBranches = [ + 'php-src.git' => ['refs/heads/PHP-5.3' => ['johannes']], + 'playground.git' => ['refs/heads/johannes' => ['nobody']] +]; function deny($reason) { @@ -126,6 +132,22 @@ if (empty($req_paths)) { $req_paths = ['']; // we can empty paths for trivial merge } +if (isset($closedBranches[$repo_name])) { + $closed = array_filter(array_keys($closedBranches[$repo_name]), + function ($branch) use ($pi) { + return in_array($branch, $pi->getBranches()); + }); + + if (count($closed)) { + $rms = $closedBranches[$repo_name]; + deny("You can not push to closed branches. ".array_map( + function ($branch) use ($rms) { + return "Please contact " . implode(', ', $rms[$branch]) . " for changes to " .. $branch . PHP_EOL; + }, + $closed)); + } +} + $restricted = []; if (isset($restrictedBranches[$repo_name])) { $restricted = array_filter($restrictedBranches[$repo_name],

« previous php.cvs (#75782) next »