Test the fixes for the shims.
authorStephen Haberman <stephen@exigencecorp.com>
Tue, 24 Jun 2008 04:31:24 +0000 (23:31 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Tue, 24 Jun 2008 04:32:37 +0000 (23:32 -0500)
server/pre-receive-trac
server/pre-receive-trac-then-noop
tests/t2001-server-pre-receive-trac-via-shim.sh

index 5fea3d9..8296f23 100644 (file)
@@ -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
index ae2d7cf..4cc3f7f 100644 (file)
@@ -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
 
index 646cf37..82e35e3 100644 (file)
@@ -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