Branch: master
Deleted commits count: 3
User: David Soria Parra <d...@php.net>         Fri, 22 Jun 2012 17:31:38 +0000

Changed paths:
  M  hooks/pre-receive
  M  lib/Git/PushInformation.php
  M  lib/Git/ReceiveHook.php


Diff:
diff --git b/hooks/pre-receive a/hooks/pre-receive
index 9b15699..2fcfe42 100755
--- b/hooks/pre-receive
+++ a/hooks/pre-receive
@@ -24,8 +24,8 @@ 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']];
+    ['php-src.git' => ['refs/heads/PHP-5.4', 'refs/heads/PHP-5.3', 
'refs/heads/master'],
+     'playground.git' => ['refs/heads/dsp']];
 
 function deny($reason)
 {
@@ -125,11 +125,15 @@ if (empty($req_paths)) {
     $req_paths = ['']; // we can empty paths for trivial merge
 }
 
-$restricted = array_filter($restrictedBranches[$repo_name], function ($branch) 
{
-    return in_array($branch, $hook->getAllBranches());
-});
+$restricted = [];
+if (isset($restrictedBranches[$repo_name])) {
+    $restricted = array_filter($restrictedBranches[$repo_name],
+        function ($branch) use ($pi) {
+            return in_array($branch, $pi->getBranches());
+        });
+}
 
-if (count($restricted) && $pi->isForced()) {
+if (count($restricted) > 0 && $pi->isForced()) {
     deny("You are allowed to overwrite commits on " . implode(', ', 
$restricted));
 }
 
diff --git b/lib/Git/PushInformation.php a/lib/Git/PushInformation.php
index 8b54161..1ee1351 100644
--- b/lib/Git/PushInformation.php
+++ a/lib/Git/PushInformation.php
@@ -92,4 +92,10 @@ class PushInformation
 
         return array_reduce($result, function($a, $b) { return $a || $b; }, 
false);
     }
+
+    public function getBranches () {
+        return $this->hook->mapInput(function ($oldrev, $newrev, $refname) {
+            return $refname;
+        });
+    }
 }
diff --git b/lib/Git/ReceiveHook.php a/lib/Git/ReceiveHook.php
index 8faedec..9db917d 100644
--- b/lib/Git/ReceiveHook.php
+++ a/lib/Git/ReceiveHook.php
@@ -83,7 +83,7 @@ abstract class ReceiveHook
      */
     protected function getChangedPaths($revRange, $reverse = false)
     {
-        $raw = \Git::gitExec('diff-tree ' . ($reverse ? '-R ' : '') . '-r 
--no-commit-id -c --name-status --pretty="format:" %s', $revRange);
+        $raw = \Git::gitExec('diff --name-status --pretty="format:" %s', 
$revRange);
         $paths = [];
         $lines = explode("\n", $raw);
         foreach($lines as $line) {


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

Reply via email to