From: Stephen Haberman Date: Tue, 24 Jun 2008 04:31:24 +0000 (-0500) Subject: Test the fixes for the shims. X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f9dd57579fb01a64cf2161818e12f05bbb755939;p=git-central.git Test the fixes for the shims. --- diff --git a/server/pre-receive-trac b/server/pre-receive-trac index 5fea3d9..8296f23 100644 --- a/server/pre-receive-trac +++ b/server/pre-receive-trac @@ -1,9 +1,8 @@ #!/bin/sh while read oldrev newrev refname ; do - if expr "$oldrev" : '0*$' >/dev/null - then - git rev-parse --not --branches | grep -v $newrev | git rev-list --stdin --no-merges $newrev + if expr "$oldrev" : '0*$' >/dev/null ; then + git rev-parse --not --branches | git rev-list --stdin --no-merges $newrev else git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin --no-merges $oldrev..$newrev fi | while read commit ; do diff --git a/server/pre-receive-trac-then-noop b/server/pre-receive-trac-then-noop index ae2d7cf..4cc3f7f 100644 --- a/server/pre-receive-trac-then-noop +++ b/server/pre-receive-trac-then-noop @@ -1,10 +1,11 @@ #!/bin/sh +nl=$'\n' input="" while read line ; do - input="$input$line" + input="$input$line$nl" done -echo $input | sh $GIT_DIR/hooks/pre-receive-trac && -echo $input | sh $GIT_DIR/hooks/noop +echo -n "$input" | sh $GIT_DIR/hooks/pre-receive-trac && +echo -n "$input" | sh $GIT_DIR/hooks/noop diff --git a/tests/t2001-server-pre-receive-trac-via-shim.sh b/tests/t2001-server-pre-receive-trac-via-shim.sh index 646cf37..82e35e3 100644 --- a/tests/t2001-server-pre-receive-trac-via-shim.sh +++ b/tests/t2001-server-pre-receive-trac-via-shim.sh @@ -7,7 +7,7 @@ test_description='server pre-receive trac ticket enforcer via shim' test_expect_success 'setup' ' echo This is a test. >a && git add a && - git commit -m "a" && + git commit -m "setup" && git clone ./. server && rm -fr server/.git/hooks && git remote add origin ./server && @@ -35,5 +35,43 @@ test_expect_success 'accept with re via shim' ' git push ' +test_expect_success 'reject second push line has bad message via shim' ' + # make a new remote branch + git branch topic1 master && + git push origin topic1 && + + # change master + echo $test_name >a && + git commit -a -m "$test_name re #3222" && + + # change topic1 with no re + git checkout topic1 && + echo "$test_name topic1" >a && + git commit -a -m "$test_name" && + head=$(git rev-parse HEAD) && + + ! git push >push.out 2>push.err && + cat push.err | grep "Commit $head does not reference a ticket" +' + +test_expect_success 'reject first push line has bad message via shim' ' + # make a new remote branch + git branch topic2 master && + git push origin topic2 && + + # change master first with no re + echo $test_name >a && + git commit -a -m "$test_name" && + head=$(git rev-parse HEAD) && + + # change topic2 with re + git checkout topic2 && + echo "$test_name topic2" >a && + git commit -a -m "$test_name re #3222" && + + ! git push >push.out 2>push.err && + cat push.err | grep "Commit $head does not reference a ticket" +' + test_done