Commit:    8141a722ca06536b935419df3111fd721d996053
Author:    David Soria Parra <[email protected]>         Fri, 22 Jun 2012 18:55:59 
+0200
Parents:   c69f9e879c21addbfa45cacd2c9dfbd10a345786
Branches:  master

Link:       
http://git.php.net/?p=karma.git;a=commitdiff;h=8141a722ca06536b935419df3111fd721d996053

Log:
Deny overwriting commits on certain branches

We don't want people to be able to use force pushes on certain branches,
such as PHP-5.4/PHP-5.3/master.

Changed paths:
  M  hooks/pre-receive


Diff:
diff --git a/hooks/pre-receive b/hooks/pre-receive
index 02789e9..9ee9be8 100755
--- a/hooks/pre-receive
+++ b/hooks/pre-receive
@@ -23,6 +23,10 @@ include 'Git/PushInformation.php';
 include 'Git/ReceiveHook.php';
 include 'Git/PreReceiveHook.php';
 
+$restrictedBranches =
+    ['php-src' => ['refs/heads/PHP-5.4', 'refs/heads/PHP-5.3', 
'refs/heads/master'],
+     'playground' => ['refs/heads/dsp']];
+
 function deny($reason)
 {
     fwrite(STDERR, $reason . "\n");
@@ -121,6 +125,14 @@ if (empty($req_paths)) {
     deny("We cannot figure out what you comitted!");
 }
 
+$restricted = array_filter($restrictedBranches[$repo_name], function ($branch) 
{
+    return in_array($branch, $hook->getAllBranches());
+});
+
+if (count($restricted) && $pi->isForced()) {
+    deny("You are allowed to overwrite commits on " . implode(', ', 
$restricted));
+}
+
 $prefix          = sprintf('%s/', $repo_name);
 $avail_lines     = $hook->getKarmaFile();
 $req_paths       = array_map(function ($x) use ($prefix) { return $prefix . 
$x;}, $req_paths);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to