[Xfce4-commits] <xfce-git-hooks:master> Enable branch deletion commit mails

Jannis Pohlmann jannis at xfce.org
Wed Aug 12 21:58:01 CEST 2009


Updating branch refs/heads/master
         to 40b35dbade8f163f5b14b9d9119b8237edeee73a (commit)
       from c27411ca9796bfebbed2cda59e3bc6716b3fceb0 (commit)

commit 40b35dbade8f163f5b14b9d9119b8237edeee73a
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Wed Aug 12 19:55:40 2009 +0000

    Enable branch deletion commit mails
    
    Unfortunately, there's no easy way to check who deleted a branch, so the
    script uses xfce-repo-admin at xfce.org as the sender.

 hooks/update-03-send-commit-mails |   77 ++++++++++++++++++++++++-------------
 1 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/hooks/update-03-send-commit-mails b/hooks/update-03-send-commit-mails
index 3c7db3f..bbd6a7b 100755
--- a/hooks/update-03-send-commit-mails
+++ b/hooks/update-03-send-commit-mails
@@ -61,7 +61,7 @@ xfce_git_hook_short_refname()
 xfce_git_hook_rev_type()
 {
   if expr "$1" : '0*$' >/dev/null; then
-    echo "unknown"
+    echo "commit"
   else
     git cat-file -t "$1"
   fi
@@ -155,10 +155,16 @@ generate_mail()
     "tracked branch"|branch)
       if expr "$prevrev" : '0*$' >/dev/null; then
         local subject="<$repository:$short_refname> Creating branch $short_refname"
+        local committer=`xfce_git_hook_committer $rev`
       else
-        local subject="<$repository:$short_refname> `xfce_git_hook_commit_subject $rev`"
+        if expr "$rev" : '0*$' > /dev/null; then
+          local subject="<$repository:$short_refname> Deleting branch $short_refname"
+          local committer="Repository admin (well, not really) <xfce-repo-admin at xfce.org>"
+        else
+          local subject="<$repository:$short_refname> `xfce_git_hook_commit_subject $rev`"
+          local committer=`xfce_git_hook_committer $rev`
+        fi
       fi
-      local committer=`xfce_git_hook_committer $rev`
       ;;
     "annotated tag")
       if expr "$prevrev" : '0*$' >/dev/null; then
@@ -187,8 +193,17 @@ From: $committer
 To: $mailinglist
 Subject: $subject
 
+EOF
+
+    if expr "$newrev" : '0*$' > /dev/null; then
+  cat <<-EOF
+Deleting $reftype $refname
+EOF
+    else
+  cat <<-EOF
 Updating $reftype $refname
 EOF
+    fi
 
     case "$reftype" in
       "tracking branch"|branch)
@@ -204,13 +219,17 @@ EOF
           echo "for the first time. Mails for the commits that lead to the creation "
           echo "of the branch will follow after this mail."
         else
-          echo "         to $rev ($revtype)"
-          echo "       from $prevrev ($prevrevtype)"
-          echo
-          git rev-list --pretty $rev ^$prevrev
-          git diff-tree --no-color --stat -M -C --find-copies-harder $rev ^$prevrev
-          echo
-          git diff-tree --no-color -p -M -C --find-copies-harder $rev ^$prevrev
+          if expr "$newrev" : '0*$' > /dev/null; then
+	    echo ""
+          else
+            echo "         to $rev ($revtype)"
+            echo "       from $prevrev ($prevrevtype)"
+            echo
+            git rev-list --pretty $rev ^$prevrev
+            git diff-tree --no-color --stat -M -C --find-copies-harder $rev ^$prevrev
+            echo
+            git diff-tree --no-color -p -M -C --find-copies-harder $rev ^$prevrev
+          fi
         fi
         ;;
       "annotated tag")
@@ -312,23 +331,27 @@ case "$newref_type" in
         sleep 1
       done
     else
-			# Now the problem is for cases like this:
-			#   * --- * --- * --- * (oldrev)
-			#          \
-			#           * --- * --- * (newrev)
-			# i.e. there is no guarantee that newrev is a strict subset
-			# of oldrev - (would have required a force, but that's allowed).
-			# So, we can't simply say rev-list $oldrev..$newrev.  Instead
-			# we find the common base of the two revs and list from there
-			baserev=`git merge-base $oldrev $newrev`
-
-      # Send commit mails for all revisions between $baserev and $newrev
-      for rev in `git rev-list --reverse $newrev ^$baserev`; do
-        prevrev=`git rev-parse $rev^1`
-        #echo "generate_mail $refname $rev $prevrev"
-        generate_mail "$refname" "$rev" "$prevrev"
-        sleep 1
-      done
+      if expr "$newrev" : '0*$' > /dev/null; then
+        generate_mail "$refname" "$newrev" "$prevrev"
+      else
+        # Now the problem is for cases like this:
+        #   * --- * --- * --- * (oldrev)
+        #          \
+        #           * --- * --- * (newrev)
+        # i.e. there is no guarantee that newrev is a strict subset
+        # of oldrev - (would have required a force, but that's allowed).
+        # So, we can't simply say rev-list $oldrev..$newrev.  Instead
+        # we find the common base of the two revs and list from there
+        baserev=`git merge-base $oldrev $newrev`
+
+        # Send commit mails for all revisions between $baserev and $newrev
+        for rev in `git rev-list --reverse $newrev ^$baserev`; do
+          prevrev=`git rev-parse $rev^1`
+          #echo "generate_mail $refname $rev $prevrev"
+          generate_mail "$refname" "$rev" "$prevrev"
+          sleep 1
+        done
+      fi
     fi
     ;;
   "annotated tag")



More information about the Xfce4-commits mailing list