Add excused to ensure follows.
authorStephen Haberman <stephen@exigencecorp.com>
Thu, 14 Aug 2008 15:51:30 +0000 (10:51 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Thu, 14 Aug 2008 15:51:30 +0000 (10:51 -0500)
server/update-ensure-follows
tests/t2700-server-ensure-follows.sh

index eedfa8a..2d5ef08 100644 (file)
@@ -15,7 +15,7 @@ oldrev="$2"
 newrev="$3"
 
 # Look up the config variable and exit if not set
-follows=$(git config hooks.ensure-follows)
+follows=$(git config hooks.update-ensure-follows.branches)
 if [[ $? -ne 0 ]] ; then
        exit 0
 fi
@@ -35,18 +35,26 @@ case "$refname" in
                ;;
 esac
 
+excused=" $(git config hooks.update-ensure-follows.excused) "
+if [[ $excused =~ " $short_refname " ]] ; then
+       exit 0
+fi
+
 follows=($follows)
 count=${#follows[@]}
 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 $follow into $short_refname"
-               echo
-               echo "----------------------------------------------------"
-               exit 1
+       git rev-parse "$follow"
+       if [ $? -eq 0 ] ; then
+               missing_commits=$(git log ^$newrev $follow --pretty=oneline | wc -l)
+               if [ $missing_commits -ne 0 ] ; then
+                       echo "----------------------------------------------------"
+                       echo
+                       echo "You need to merge $follow into $short_refname"
+                       echo
+                       echo "----------------------------------------------------"
+                       exit 1
+               fi
        fi
 done
 
index b456525..a5eb1fa 100644 (file)
@@ -25,7 +25,7 @@ test_expect_success 'pushing stable works' '
 
 test_expect_success 'branch with unmoved stable is okay' '
        cd server &&
-       git config hooks.ensure-follows stable &&
+       git config hooks.update-ensure-follows.branches stable &&
        cd .. &&
 
        git checkout -b topic1 &&
@@ -53,7 +53,7 @@ test_expect_success 'branch with moved stable requires merge' '
 
 test_expect_success 'branch with moved stable as second branch requires merge' '
        cd server &&
-       git config hooks.ensure-follows "foo stable" &&
+       git config hooks.update-ensure-follows.branches "foo stable" &&
        cd .. &&
 
        git checkout stable &&
@@ -86,7 +86,32 @@ 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
+
+       git push origin :topic1
+'
+
+test_expect_success 'excused branch with moved stable is okay' '
+       git checkout -b topic2 stable &&
+       echo "$test_name" >a.topic2 &&
+       git add a.topic2 &&
+       git commit -m "Change on topic2" &&
+       git push origin topic2 &&
+
+       git checkout stable &&
+       echo "$test_name" >a &&
+       git commit -a -m "Change on stable" &&
+       git push origin stable &&
+
+       git checkout topic2 &&
+       echo "$test_name foo" >a.topic2 &&
+       git commit -a -m "Change on topic2 again" &&
+       ! git push origin topic2 &&
+
+       cd server &&
+       git config hooks.update-ensure-follows.excused topic2 &&
+       cd .. &&
+
+       git push origin topic2
 '
 
 test_done