The branch, PHP_POST_RECEIVE on karma.git has been updated
       via  c7163b23683f8656f913ff4d22706ca5a5f41380 (commit)
      from  67c322fe22b0cb6f561711a4041325974b9bfc31 (commit)

http://git.php.net/?p=karma.git;a=log;h=c7163b23683f8656f913ff4d22706ca5a5f41380;hp=67c322fe22b0cb6f561711a4041325974b9bfc31

Summary of changes:
 README.POST_RECEIVE         |    6 ++----
 lib/Git/PostReceiveHook.php |   26 ++++++++++++++++----------
 2 files changed, 18 insertions(+), 14 deletions(-)

-- Log ----------------------------------------
commit c7163b23683f8656f913ff4d22706ca5a5f41380
Author: Alexander Moskaliov <ir...@php.net>
Date:   Wed Mar 7 11:49:54 2012 +0400

    Add info about force push

diff --git a/README.POST_RECEIVE b/README.POST_RECEIVE
index 90a9f59..fe0a666 100644
--- a/README.POST_RECEIVE
+++ b/README.POST_RECEIVE
@@ -63,10 +63,8 @@ This part contains info only about mail per branch. For mail 
per commit logic di
     It's mean user used --force option for pull and remove previosly revisions.
     (rewind N revision in first case and replace 5-O revisions by 4-N)
     We can check it by command: git rev-list N..O.
-    If result of this command not empty - we have such cases.
-    If result of "git merge-base O N" will be equal N  - we have first case.
-    We send mail with info about rewind or replace.
-    (Realization of this case in progress)
+    If result of this command not empty - we have such cases, and this
+    result is list of discarded revisions.
 
 
 ------------
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index 49e5499..c34a55b 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -49,14 +49,13 @@ class PostReceiveHook extends ReceiveHook
         foreach ($this->refs as $ref) {
             if ($ref['reftype'] == self::REF_TAG) {
                 $this->sendTagMail($ref);
-            } else {
+            } elseif ($ref['reftype'] == self::REF_BRANCH){
                 $this->sendBranchMail($ref);
             }
         }
 
         // TODO: For new branches we must check if this branch was
         // cloned from other branch in this push - it's especial case
-        // TODO: check old post-receive for other especial cases
 
         foreach ($this->revisions as $revision => $branches) {
             // check if it commit was already in other branches
@@ -82,10 +81,15 @@ class PostReceiveHook extends ReceiveHook
 
         if ($branch['changetype'] != self::TYPE_DELETED) {
 
-            // TODO: cache revisions to $this->revisions
             if ($branch['changetype'] == self::TYPE_UPDATED) {
+                // check if push was with --forced option
+                if ($replacedRevisions = $this->getRevisions($branch['new'] . 
'..' . $branch['old'])) {
+                    $message .= "Discarded revisions: \n" . implode("\n", 
$replacedRevisions) . "\n";
+                }
+
                 // git rev-list old..new
                 $revisions = $this->getRevisions($branch['old'] . '..' . 
$branch['new']);
+
             } else {
                 // for new branch we write log about new commits only
                 $revisions = $this->getRevisions($branch['new']. ' --not ' . 
implode(' ', $this->allBranches));
@@ -93,14 +97,16 @@ class PostReceiveHook extends ReceiveHook
 
             $this->cacheRevisions($branch['refname'], $revisions);
 
-            $message .= "--------LOG--------\n";
-            foreach ($revisions as $revision) {
-                $diff = $this->execute(
-                    'git diff-tree --stat --pretty=medium -c %s',
-                    $revision
-                );
+            if (count($revisions)) {
+                $message .= "--------LOG--------\n";
+                foreach ($revisions as $revision) {
+                    $diff = $this->execute(
+                        'git diff-tree --stat --pretty=medium -c %s',
+                        $revision
+                    );
 
-                $message .= $diff."\n\n";
+                    $message .= $diff."\n\n";
+                }
             }
         }
 

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