Allow tags to lag stable.
authorStephen Haberman <stephen@exigencecorp.com>
Wed, 13 Aug 2008 17:54:28 +0000 (12:54 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Wed, 13 Aug 2008 17:55:20 +0000 (12:55 -0500)
server/update-ensure-follows
tests/t2700-server-ensure-follows.sh

index 09239ba..eedfa8a 100644 (file)
@@ -1,6 +1,12 @@
 #!/bin/sh
 #
-# When updating a branch, it must include the tip of stable.
+# When updating a branch, ensure it has the latest changes
+# from other branches, e.g. stable.
+#
+# While this forces merging sooner than devs may like, it
+# assures deployment and qa staff that the latest revisions
+# they are qa'ing will always have the last stable release
+# in it.
 #
 
 # Command line
@@ -8,26 +14,36 @@ refname="$1"
 oldrev="$2"
 newrev="$3"
 
-# Branch deletions are okay
-# if expr "$newrev" : '0*$' >/dev/null ; then
-# exit 0
-# fi
-
 # Look up the config variable and exit if not set
 follows=$(git config hooks.ensure-follows)
 if [[ $? -ne 0 ]] ; then
-    exit 0
+       exit 0
 fi
 
+# Branch deletions are okay
+if expr "$newrev" : '0*$' >/dev/null ; then
+       exit 0
+fi
+
+# We only care about branches moving--ignore tags.
+case "$refname" in
+       refs/heads/*)
+               short_refname=${refname##refs/heads/}
+               ;;
+       *)
+               exit 0
+               ;;
+esac
+
 follows=($follows)
 count=${#follows[@]}
-for (( i = 0 ; i < count ; i++)) do
+for ((i = 0 ; i < count ; i++)) do
        follow="${follows[$i]}"
        missing_commits=$(git log ^$newrev $follow --pretty=oneline | wc -l)
        if [ $missing_commits -ne 0 ] ; then
                echo "----------------------------------------------------"
                echo
-               echo "You need to merge with $follow"
+               echo "You need to merge $follow into $short_refname"
                echo
                echo "----------------------------------------------------"
                exit 1
index 68a0052..b456525 100644 (file)
@@ -45,7 +45,7 @@ test_expect_success 'branch with moved stable requires merge' '
        echo "$test_name" >a.topic1 &&
        git commit -a -m "Change on topic1." &&
        ! git push origin topic1 2>push.err &&
-       cat push.err | grep "You need to merge with stable" &&
+       cat push.err | grep "You need to merge stable into topic1" &&
 
        git merge stable &&
        git push origin topic1
@@ -65,11 +65,29 @@ test_expect_success 'branch with moved stable as second branch requires merge' '
        echo "$test_name" >a.topic1 &&
        git commit -a -m "Change on topic1." &&
        ! git push origin topic1 2>push.err &&
-       cat push.err | grep "You need to merge with stable" &&
+       cat push.err | grep "You need to merge stable into topic1" &&
 
        git merge stable &&
        git push origin topic1
 '
 
+test_expect_success 'tag with moved stable is okay' '
+       git checkout stable &&
+       echo "$test_name" >a &&
+       git commit -a -m "Change on stable" &&
+       git push origin stable &&
+
+       git checkout topic1 &&
+       git tag topic1-tag1
+       git push --tags
+'
+
+test_expect_success 'branch deletion with moved stable is okay' '
+       git checkout stable &&
+       echo "$test_name" >a &&
+       git commit -a -m "Change on stable" &&
+       git push origin :stable
+'
+
 test_done