The branch master on karma.git has been updated
       via  0b0820cdba2232799df7918e198ca4acf7bfe9fe (commit)
       via  186bf0765eedc06ef7ec590089d997efeda72d64 (commit)
       via  7c4de5d5a9e10eb0322d87e69f07e32ad843de60 (commit)
       via  34f6910a46bbdaf32871f9cb1cda1c41d26ca96f (commit)
       via  f2e733020f4a75f4a91b88ea73c0c8c77f455d5c (commit)
       via  3cb77b79f3dc1a5a77cb3c4348b7a14b3e29aca2 (commit)
       via  cffd3b39b05fae71090586fcc9f717f857c20ae0 (commit)
       via  99a863d4846676c53e15031cdc217c264aa082f8 (commit)
       via  91e9caf26371fc75f01faa4a1e7f0a9729313c4e (commit)
       via  8965fe78b0a0e1a1fca87677183472a8eb0ae8e9 (commit)
       via  57727b422a5df298c6db0ba73d2aa4eab3b76fb8 (commit)
       via  b8e2e76374106a75687c430597ac8a352c7e514e (commit)
       via  30a1031bfb19338e8eb5cfabc72c7352d6f38a18 (commit)
       via  a7fabb3c3cf3274a48efe8d7ae948af68984f0d1 (commit)
       via  4d61fb520544f543d8c6120fb02548de4bfc2f06 (commit)
       via  fc047465fda04319c5a14707d7709fff1f2a3f57 (commit)
       via  b1240df188897323ee2c550d62fcab4a245bec37 (commit)
       via  8507e88c7abde403c9bdf1b385d5d4f2b284d1f3 (commit)
       via  509b56df21c8cd0ee971c9580adadc00379df8b1 (commit)
       via  454db4da98f95049825b3a9018542d709136a7bc (commit)
       via  e41adefbee4ab8758d42a360eeaecd5e22bb7e30 (commit)
       via  46adcc9c1571d5a20660ca49b2762189a1495786 (commit)
       via  c7163b23683f8656f913ff4d22706ca5a5f41380 (commit)
       via  67c322fe22b0cb6f561711a4041325974b9bfc31 (commit)
       via  b841aacab5e1e9af103b1d38e11822debda5ea22 (commit)
       via  89a2d90e9e5d2e8a661b91c1fdb3f32cf2d90cdd (commit)
       via  5d58ad7ac1700df5ad7d9bf50b73b80b71ce9844 (commit)
       via  373c2053d9ac29ab7d2750b25e939a5b4a0dfc17 (commit)
      from  fc9c78fe12aa756060684e565adf8fb8a4373120 (commit)

http://git.php.net/?p=karma.git;a=log;h=0b0820cdba2232799df7918e198ca4acf7bfe9fe;hp=fc9c78fe12aa756060684e565adf8fb8a4373120

Summary of changes:
 README.POST_RECEIVE_MAIL    |  119 +++++++
 hooks/post-receive          |  753 +------------------------------------------
 hooks/post-receive.mail     |   50 +++
 hooks/pre-receive           |    6 +-
 lib/Git.php                 |   28 ++-
 lib/Git/PostReceiveHook.php |  573 ++++++++++++++++++++++++++++++++
 lib/Git/PreReceiveHook.php  |   75 +++++
 lib/Git/PushInformation.php |   28 +-
 lib/Git/ReceiveHook.php     |  186 ++++++------
 lib/Mail.php                |  185 +++++++++++
 10 files changed, 1136 insertions(+), 867 deletions(-)
 create mode 100644 README.POST_RECEIVE_MAIL
 create mode 100755 hooks/post-receive.mail
 create mode 100644 lib/Git/PostReceiveHook.php
 create mode 100644 lib/Git/PreReceiveHook.php
 create mode 100644 lib/Mail.php

-- Log ----------------------------------------
commit 0b0820cdba2232799df7918e198ca4acf7bfe9fe
Merge: 186bf07 7c4de5d
Author: David Soria Parra <d...@php.net>
Date:   Sun Mar 18 16:30:22 2012 +0100

    Merge remote-tracking branch 'origin/PHP_POST_RECEIVE'
    
    Conflicts:
        lib/Git/ReceiveHook.php

diff --cc hooks/pre-receive
index 424ce41,250b609..95224ff
--- a/hooks/pre-receive
+++ b/hooks/pre-receive
@@@ -111,9 -112,10 +112,10 @@@ if ($hook->isKarmaIgnored()) 
      accept("No karma check necessary. Thank you for your contribution.\n");
  }
  
+ $hook->hookInput();
  $repo_name = $hook->getRepositoryName();
  $pi        = new \Git\PushInformation($hook);
 -$req_paths = ($pi->isForced()) ? [''] : $hook->getReceivedPaths();
 +$req_paths = ($pi->isForced() || $pi->isTag()) ? [''] : 
$hook->getReceivedPaths();
  
  if (empty($req_paths)) {
      deny("We cannot figure out what you comitted!");
diff --cc lib/Git/PreReceiveHook.php
index 0000000,eb0c609..be707ad
mode 000000,100644..100644
--- a/lib/Git/PreReceiveHook.php
+++ b/lib/Git/PreReceiveHook.php
@@@ -1,0 -1,75 +1,75 @@@
+ <?php
+ namespace Git;
+ 
+ class PreReceiveHook extends ReceiveHook
+ {
+ 
+     private $karmaFile;
+ 
+     public function __construct($karma_file, $base_path)
+     {
+         parent::__construct($base_path);
+         $this->karmaFile = $karma_file;
+     }
+ 
+     /**
+     * Returns true if git option karma.ignored is set, otherwise false.
+     *
+     * @return boolean
+     */
+     public function isKarmaIgnored()
+     {
+         return 'true' === \Git::gitExec('config karma.ignored');
+     }
+ 
+     public function mapInput(callable $fn) {
+         $result = [];
+         foreach($this->refs as $input) {
 -            $result[] = $fn($input['old'], $input['new']);
++            $result[] = $fn($input['old'], $input['new'], $input['refname']);
+         }
+ 
+         return $result;
+     }
+ 
+     /**
+     * Return the content of the karma file from the karma repository.
+     *
+     * We read the content of the karma file from the karma repository index.
+     *
+     * @return string
+     */
+     public function getKarmaFile()
+     {
+         return file($this->karmaFile);
+     }
+ 
+     public function getReceivedPaths()
+     {
+         // escaped branches
+         $allBranches =$this->escapeArrayShellArgs($this->getAllBranches());
+ 
+         $paths = array_map(
+             function ($input) use ($allBranches) {
+                 $paths = [];
+ 
+                 if ($input['changetype'] == self::TYPE_CREATED) {
+                     $paths = 
$this->getChangedPaths(escapeshellarg($input['new']) . ' --not ' . implode(' ', 
$allBranches));
+                 } elseif ($input['changetype'] == self::TYPE_UPDATED) {
+                     $paths = 
$this->getChangedPaths(escapeshellarg($input['old'] . '..' . $input['new']));
+                 } else {
+                     // deleted branch. we also need some paths
+                     // to check karma
+                 }
+ 
+                 return array_keys($paths);
+             },
+             $this->refs
+         );
+ 
+         /* flattern the array */
+         $paths = array_reduce($paths, 'array_merge', []);
+ 
+ 
+         return array_unique($paths);
+     }
+ }

commit 186bf0765eedc06ef7ec590089d997efeda72d64
Author: David Soria Parra <d...@php.net>
Date:   Sun Mar 18 16:27:46 2012 +0100

    Check for tags

diff --git a/hooks/pre-receive b/hooks/pre-receive
index 6a7c29f..424ce41 100755
--- a/hooks/pre-receive
+++ b/hooks/pre-receive
@@ -113,7 +113,7 @@ if ($hook->isKarmaIgnored()) {
 
 $repo_name = $hook->getRepositoryName();
 $pi        = new \Git\PushInformation($hook);
-$req_paths = ($pi->isForced()) ? [''] : $hook->getReceivedPaths();
+$req_paths = ($pi->isForced() || $pi->isTag()) ? [''] : 
$hook->getReceivedPaths();
 
 if (empty($req_paths)) {
     deny("We cannot figure out what you comitted!");
diff --git a/lib/Git/PushInformation.php b/lib/Git/PushInformation.php
index edf73dc..10437da 100644
--- a/lib/Git/PushInformation.php
+++ b/lib/Git/PushInformation.php
@@ -83,4 +83,17 @@ class PushInformation
 
         return array_reduce($result, function($a, $b) { return $a || $b; }, 
false);
     }
+
+    public function isTag()
+    {
+        $result = $this->hook->mapInput(
+            function($oldrev, $newrev, $refname) {
+                if (preg_match('@^refs/tags/.+@i', $refname)) {
+                    return true;
+                }
+                return false;
+            });
+
+        return array_reduce($result, function($a, $b) { return $a || $b; }, 
false);
+    }
 }
diff --git a/lib/Git/ReceiveHook.php b/lib/Git/ReceiveHook.php
index b51a5f4..fd4ee35 100644
--- a/lib/Git/ReceiveHook.php
+++ b/lib/Git/ReceiveHook.php
@@ -45,7 +45,7 @@ class ReceiveHook
     public function mapInput(callable $fn) {
         $result = [];
         foreach($this->hookInput() as $input) {
-            $result[] = $fn($input['old'], $input['new']);
+            $result[] = $fn($input['old'], $input['new'], $input['refname']);
         }
 
         return $result;

Thank you for your contribution.

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

Reply via email to