Allow branches to be excused from the ticket check.
authorStephen Haberman <stephen@exigencecorp.com>
Thu, 14 Aug 2008 15:33:11 +0000 (10:33 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Thu, 14 Aug 2008 15:33:11 +0000 (10:33 -0500)
server/update-ensure-ticket-reference
tests/t2002-server-update-ensure-ticket-reference-branches.sh

index 5d6014c..33acbc7 100644 (file)
@@ -5,6 +5,22 @@ refname="$1"
 oldrev="$2"
 newrev="$3"
 
+# We only care about branches moving--ignore tags/etc.
+case "$refname" in
+       refs/heads/*)
+               short_refname=${refname##refs/heads/}
+               ;;
+       *)
+               exit 0
+               ;;
+esac
+
+
+excused=" $(git config hooks.update-ensure-ticket-reference.excused) "
+if [[ $excused =~ " $short_refname " ]] ; then
+       exit 0
+fi
+
 if expr "$oldrev" : '0*$' >/dev/null ; then
        git rev-parse --not --branches | git rev-list --stdin --no-merges $newrev
 else
index be34923..5e12566 100644 (file)
@@ -16,7 +16,7 @@ test_expect_success 'setup' '
 '
 
 # setup the hook
-install_server_hook 'update-ensure-ticket-reference' 'update'
+install_update_hook 'update-ensure-ticket-reference'
 
 test_expect_success 'reject new branch with bad message' '
        git checkout -b topic1 master &&
@@ -68,5 +68,19 @@ test_expect_success 'accept new branch with re in all of three' '
        git push origin topic4
 '
 
+test_expect_success 'accept branch that has been excused' '
+       git checkout -b topic5 master &&
+       echo "$test_name first" >a &&
+       git commit -a -m "$test_name first with no re" &&
+
+       ! git push origin topic5
+
+       cd server
+       git config hooks.update-ensure-ticket-reference.excused topic5
+       cd ..
+
+       git push origin topic5
+'
+
 test_done