From: Stephen Haberman Date: Fri, 20 Jun 2008 01:39:41 +0000 (-0500) Subject: Test branch creation--turns out we still need to only log new commits to avoid valida... X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=36f076f853efd4479bab1fa42805a0ac10736993;p=git-central.git Test branch creation--turns out we still need to only log new commits to avoid validating everything back to the rev 0. --- diff --git a/server/pre-receive-ticket b/server/pre-receive-ticket index 7858585..7614975 100644 --- a/server/pre-receive-ticket +++ b/server/pre-receive-ticket @@ -3,9 +3,9 @@ while read oldrev newrev refname ; do if expr "$oldrev" : '0*$' >/dev/null then - git rev-list $newrev + git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $newrev else - git rev-list $oldrev..$newrev + git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $oldrev..$newrev fi | while read commit ; do git log -n 1 '--pretty=format:%s%n%b' "$commit" | grep -i '\(\(re\|refs\|qa\) #[0-9]\+\)\|\(no ticket\)' > /dev/null if [ $? -ne 0 ] diff --git a/tests/t2002-server-pre-receive-ticket-branches.sh b/tests/t2002-server-pre-receive-ticket-branches.sh new file mode 100644 index 0000000..f9bfea0 --- /dev/null +++ b/tests/t2002-server-pre-receive-ticket-branches.sh @@ -0,0 +1,39 @@ + +#!/bin/sh + +test_description='server pre-receive ticket enforcer via shim' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo "setup" >a && + git add a && + git commit -m "setup" && + git clone ./. server && + rm -fr server/.git/hooks && + git remote add origin ./server && + git config --add branch.master.remote origin && + git config --add branch.master.merge refs/heads/master +' + +# setup the hook +install_server_hook 'pre-receive-ticket' 'pre-receive' + +test_expect_success 'reject new branch with bad message' ' + git checkout -b topic1 + echo $test_name >a && + git commit -a -m "$test_name" && + head=$(git rev-parse HEAD) + git push origin topic1 >push.out 2>push.err + cat push.err | grep "Commit $head does not reference a ticket" +' + +# the last test has a dirty commit message, so ammend it with a good message +test_expect_success 'accept new branch with re' ' + echo $test_name >a && + git commit --amend -m "$test_name re #3222" && + git push origin topic1 +' + +test_done +