From 4d6f4184dd4341f375863fcfdae487f0886d53ad Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Thu, 19 Jun 2008 22:48:02 -0500 Subject: [PATCH] Test new branches--can't use rev-parse yet as the ref doesn't exist. --- server/pre-receive-ticket | 2 +- ...2002-server-pre-receive-ticket-branches.sh | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/server/pre-receive-ticket b/server/pre-receive-ticket index 7614975..1553afe 100644 --- a/server/pre-receive-ticket +++ b/server/pre-receive-ticket @@ -3,7 +3,7 @@ while read oldrev newrev refname ; do if expr "$oldrev" : '0*$' >/dev/null then - git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $newrev + git rev-parse --not --branches | grep -v $newrev | git rev-list --stdin $newrev else git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $oldrev..$newrev fi | while read commit ; do diff --git a/tests/t2002-server-pre-receive-ticket-branches.sh b/tests/t2002-server-pre-receive-ticket-branches.sh index f9bfea0..b572625 100644 --- a/tests/t2002-server-pre-receive-ticket-branches.sh +++ b/tests/t2002-server-pre-receive-ticket-branches.sh @@ -20,7 +20,7 @@ test_expect_success 'setup' ' install_server_hook 'pre-receive-ticket' 'pre-receive' test_expect_success 'reject new branch with bad message' ' - git checkout -b topic1 + git checkout -b topic1 master echo $test_name >a && git commit -a -m "$test_name" && head=$(git rev-parse HEAD) @@ -30,9 +30,43 @@ test_expect_success 'reject new branch with bad message' ' # the last test has a dirty commit message, so ammend it with a good message test_expect_success 'accept new branch with re' ' + git checkout -b topic2 master echo $test_name >a && git commit --amend -m "$test_name re #3222" && - git push origin topic1 + git push origin topic2 +' + +test_expect_success 'reject new branch with bad message in second of three' ' + git checkout -b topic3 master + echo "$test_name first" >a && + git commit -a -m "$test_name first re #3222" && + + # the bad one + echo "$test_name second" >a && + git commit -a -m "$test_name second" && + head=$(git rev-parse HEAD) + + echo "$test_name third" >a && + git commit -a -m "$test_name third re #3222" && + + git push origin topic3 >push.out 2>push.err + cat push.err | grep "Commit $head does not reference a ticket" +' + +test_expect_success 'accept new branch with re in all of three' ' + git checkout -b topic4 master + echo "$test_name first" >a && + git commit -a -m "$test_name first re #3222" && + + # the bad one + echo "$test_name second" >a && + git commit -a -m "$test_name second re #3222" && + head=$(git rev-parse HEAD) + + echo "$test_name third" >a && + git commit -a -m "$test_name third re #3222" && + + git push origin topic4 ' test_done -- 2.39.5