[Xfce4-commits] <xfce-git-hooks:master> rename first hook and check a few more things

Brian J. Tarricone brian at tarricone.org
Wed Aug 12 21:28:09 CEST 2009


Updating branch refs/heads/master
         to 0f01c38f57b467a9a8ce45e4fe432b2dc6ba38cb (commit)
       from 6579f04a597911dec7d4cac4d8ab37dfe0622997 (commit)

commit 0f01c38f57b467a9a8ce45e4fe432b2dc6ba38cb
Author: Brian J. Tarricone <brian at tarricone.org>
Date:   Tue Aug 11 00:58:55 2009 -0700

    rename first hook and check a few more things

 hooks/update-01-block-commits-to-tags |   20 ---------
 hooks/update-01-history-integrity     |   75 +++++++++++++++++++++++++++++++++
 update                                |    2 +-
 3 files changed, 76 insertions(+), 21 deletions(-)

diff --git a/hooks/update-01-block-commits-to-tags b/hooks/update-01-block-commits-to-tags
deleted file mode 100755
index 49b1ec2..0000000
--- a/hooks/update-01-block-commits-to-tags
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-refname=$1
-oldrev=$2
-newrev=$3
-
-[ "$newrev" ] || exit 1
-
-case $refname in
-  refs/tags/*)
-    if git rev-parse --verify -q "$refname"; then
-      echo "Modifying existing tags is not allowed" >&2
-      exit 1
-    fi
-    ;;
-  *)
-    ;;
-esac
-
-exit 0
diff --git a/hooks/update-01-history-integrity b/hooks/update-01-history-integrity
new file mode 100755
index 0000000..b185baa
--- /dev/null
+++ b/hooks/update-01-history-integrity
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+refname=$1
+oldrev=$2
+newrev=$3
+
+[ "$newrev" ] || exit 1
+
+if [ "$newrev" = "0000000000000000000000000000000000000000" ]; then
+	newrev_type=delete
+else
+	newrev_type=$(git-cat-file -t $newrev)
+fi
+
+is_fast_forward()
+{
+  old=$1
+  new=$2
+
+  for sha in `git rev-list "$new"`; do
+    if [ "$sha" = "$old" ]; then
+      return 0
+    fi
+  done
+  
+  return 1
+}
+
+case $refname in
+  refs/tags/*)
+    # don't allow modification of existing tags
+    if git rev-parse --verify -q "$refname"; then
+      echo "Modifying existing tags is not allowed." >&2
+      exit 1
+    fi
+
+    # don't allow "lightweight" non-annotated tags
+    if [ "$newrev_type" = "commit" ]; then
+      echo "Pushing 'lightweight' non-annotated tags is not allowed." >&2
+      echo "You can create a full tag using the -a, -s, or -u options" >&2
+      echo "to the 'git tag' command.  It is highly recommended that you" >&2
+      echo "sign your tags using -s or -u." >&2
+      exit 1
+    fi
+    ;;
+  
+  refs/heads/master)
+    if [ "$newrev_type" = "delete" ]; then
+      echo "Deleting the master branch is not allowed." >&2
+      exit 1
+    fi
+
+    if ! is_fast_forward $refname $newrev
+      echo "Non-fast forward update not allowed for master branch." >&2
+      exit 1
+    fi
+    ;;
+
+  refs/heads/xfce-4.*)
+    if [ "$newrev_type" = "delete" ]; then
+      echo "Deleting xfce stable branches is not allowed." >&2
+      exit 1
+    fi
+
+    if ! is_fast_forward $refname $newrev
+      echo "Non-fast forward update not allowed for xfce stable branches." >&2
+      exit 1
+    fi
+    ;;
+
+  *)
+    ;;
+esac
+
+exit 0
diff --git a/update b/update
index e0b7603..f859c62 100755
--- a/update
+++ b/update
@@ -31,7 +31,7 @@ parent="`dirname $path`"
 export REPO="`basename $parent`/`basename $path`"
 unset parent path
 
-$XFCE_GIT_HOOK_DIR/hooks/update-01-block-commits-to-tags "$@" &&
+$XFCE_GIT_HOOK_DIR/hooks/update-01-history-integrity "$@" &&
 $XFCE_GIT_HOOK_DIR/hooks/update-02-check-permissions "$@" &&
 $XFCE_GIT_HOOK_DIR/hooks/update-03-send-commit-mails "$@"
 exit $?



More information about the Xfce4-commits mailing list