From 3c0e11d736151883a52f957eac85485799278f2a Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Thu, 14 Aug 2008 10:33:11 -0500 Subject: [PATCH] Allow branches to be excused from the ticket check. --- server/update-ensure-ticket-reference | 16 ++++++++++++++++ ...er-update-ensure-ticket-reference-branches.sh | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/server/update-ensure-ticket-reference b/server/update-ensure-ticket-reference index 5d6014c..33acbc7 100644 --- a/server/update-ensure-ticket-reference +++ b/server/update-ensure-ticket-reference @@ -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 diff --git a/tests/t2002-server-update-ensure-ticket-reference-branches.sh b/tests/t2002-server-update-ensure-ticket-reference-branches.sh index be34923..5e12566 100644 --- a/tests/t2002-server-update-ensure-ticket-reference-branches.sh +++ b/tests/t2002-server-update-ensure-ticket-reference-branches.sh @@ -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 -- 2.39.5