Convert trac to update instead of pre-receive.
authorStephen Haberman <stephen@exigencecorp.com>
Tue, 24 Jun 2008 17:30:12 +0000 (12:30 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Tue, 24 Jun 2008 17:30:12 +0000 (12:30 -0500)
12 files changed:
cbas/pre-receive
cbas/update
server/pre-receive-trac [deleted file]
server/pre-receive-trac-then-noop [deleted file]
server/update-trac [new file with mode: 0644]
tests/t2000-server-pre-receive-trac.sh [deleted file]
tests/t2000-server-update-trac.sh [new file with mode: 0644]
tests/t2001-server-pre-receive-trac-via-shim.sh [deleted file]
tests/t2001-server-update-trac-merges.sh [new file with mode: 0644]
tests/t2002-server-pre-receive-trac-branches.sh [deleted file]
tests/t2002-server-update-trac-branches.sh [new file with mode: 0644]
tests/t2003-server-pre-receive-trac-merges.sh [deleted file]

index fa7e124..800f366 100755 (executable)
@@ -7,7 +7,5 @@ while read newref oldref refname ; do
 done
 
 echo -n "$input" | sh /srv/git/hooks/server/pre-receive-only-one &&
-echo -n "$input" | sh /srv/git/hooks/server/pre-receive-prefer-rebase &&
-echo -n "$input" | sh /srv/git/hooks/server/pre-receive-stable &&
-echo -n "$input" | sh /srv/git/hooks/server/pre-receive-trac
+echo -n "$input" | sh /srv/git/hooks/server/pre-receive-stable
 
index d03ca30..baa1bdb 100755 (executable)
@@ -4,6 +4,7 @@ refname="$1"
 oldrev="$2"
 newrev="$3"
 
-/srv/git/hooks/server/update-allow-tags-branches "$refname" "$oldrev" "$newrev" &&
-/srv/git/hooks/server/update-prefer-rebase "$refname" "$oldrev" "$newrev"
+sh /srv/git/hooks/server/update-trac "$refname" "$oldrev" "$newrev" &&
+sh /srv/git/hooks/server/update-allow-tags-branches "$refname" "$oldrev" "$newrev" &&
+sh /srv/git/hooks/server/update-prefer-rebase "$refname" "$oldrev" "$newrev"
 
diff --git a/server/pre-receive-trac b/server/pre-receive-trac
deleted file mode 100644 (file)
index 8296f23..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-while read oldrev newrev refname ; do
-       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
-               git log -n 1 '--pretty=format:%s%n%b' "$commit" | grep -i '\(\(re\|refs\|qa\) #[0-9]\+\)\|\(no ticket\)' > /dev/null
-               if [ $? -ne 0 ] ; then
-                       echo "Commit $commit does not reference a ticket"
-                       exit 1
-               fi
-       done
-       if [ $? -ne 0 ] ; then
-               exit 1
-       fi
-done
-
diff --git a/server/pre-receive-trac-then-noop b/server/pre-receive-trac-then-noop
deleted file mode 100644 (file)
index 4cc3f7f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-nl=$'\n'
-input=""
-while read line ; do
-    input="$input$line$nl"
-done
-
-echo -n "$input" | sh $GIT_DIR/hooks/pre-receive-trac &&
-echo -n "$input" | sh $GIT_DIR/hooks/noop
-
diff --git a/server/update-trac b/server/update-trac
new file mode 100644 (file)
index 0000000..3b97545
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Command line
+refname="$1"
+oldrev="$2"
+newrev="$3"
+
+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 | git rev-list --stdin --no-merges $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 ] ; then
+               echo "Commit $commit does not reference a ticket"
+               exit 1
+       fi
+done
+
diff --git a/tests/t2000-server-pre-receive-trac.sh b/tests/t2000-server-pre-receive-trac.sh
deleted file mode 100644 (file)
index 38d3946..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-
-test_description='server pre-receive trac ticket enforcer'
-
-. ./test-lib.sh
-
-test_expect_success 'setup' '
-       echo This is a test. >a &&
-       git add a &&
-       git commit -m "a" &&
-       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 pre-receive hook
-install_server_hook 'pre-receive-trac' 'pre-receive'
-
-test_expect_success 'reject with bad message' '
-       echo $test_name >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"
-'
-
-# the last test has a dirty commit message, so ammend it with a good message
-test_expect_success 'accept with re' '
-       echo $test_name >a &&
-       git commit --amend -m "$test_name re #3222" &&
-       git push
-'
-
-test_expect_success 'accept with re on second line' '
-       echo $test_name >a &&
-       echo "first subject line" >msg
-       echo "second line re #322" >>msg
-       git commit -a -F msg &&
-       git push
-'
-
-test_expect_success 'reject with bad message in second of three' '
-       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 "head=$head" &&
-
-       echo "$test_name third" >a &&
-       git commit -a -m "$test_name third re #3222" &&
-
-       ! git push >push.out 2>push.err &&
-       cat push.err | grep "Commit $head does not reference a ticket"
-'
-
-test_expect_success 'accept with re in all of three' '
-       git reset --hard HEAD^^^ &&
-       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
-'
-
-test_done
-
diff --git a/tests/t2000-server-update-trac.sh b/tests/t2000-server-update-trac.sh
new file mode 100644 (file)
index 0000000..ff600f2
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+test_description='server update trac ticket enforcer'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       echo This is a test. >a &&
+       git add a &&
+       git commit -m "a" &&
+       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 update hook
+install_server_hook 'update-trac' 'update'
+
+test_expect_success 'reject with bad message' '
+       echo $test_name >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"
+'
+
+# the last test has a dirty commit message, so ammend it with a good message
+test_expect_success 'accept with re' '
+       echo $test_name >a &&
+       git commit --amend -m "$test_name re #3222" &&
+       git push
+'
+
+test_expect_success 'accept with re on second line' '
+       echo $test_name >a &&
+       echo "first subject line" >msg
+       echo "second line re #322" >>msg
+       git commit -a -F msg &&
+       git push
+'
+
+test_expect_success 'reject with bad message in second of three' '
+       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 "head=$head" &&
+
+       echo "$test_name third" >a &&
+       git commit -a -m "$test_name third re #3222" &&
+
+       ! git push >push.out 2>push.err &&
+       cat push.err | grep "Commit $head does not reference a ticket"
+'
+
+test_expect_success 'accept with re in all of three' '
+       git reset --hard HEAD^^^ &&
+       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
+'
+
+test_done
+
diff --git a/tests/t2001-server-pre-receive-trac-via-shim.sh b/tests/t2001-server-pre-receive-trac-via-shim.sh
deleted file mode 100644 (file)
index 82e35e3..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-
-test_description='server pre-receive trac ticket enforcer via shim'
-
-. ./test-lib.sh
-
-test_expect_success 'setup' '
-       echo This is a test. >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 shim
-install_server_hook 'noop' 'noop'
-install_server_hook 'pre-receive-trac' 'pre-receive-trac'
-install_server_hook 'pre-receive-trac-then-noop' 'pre-receive'
-
-test_expect_success 'reject with bad message via shim' '
-       echo $test_name >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"
-'
-
-# the last test has a dirty commit message, so ammend it with a good message
-test_expect_success 'accept with re via shim' '
-       echo $test_name >a &&
-       git commit --amend -m "$test_name re #3222" &&
-       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
-
diff --git a/tests/t2001-server-update-trac-merges.sh b/tests/t2001-server-update-trac-merges.sh
new file mode 100644 (file)
index 0000000..a8851a0
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='server update trac 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 'update-trac' 'update'
+
+test_expect_success 'accept merge with merge message' '
+       git checkout -b topic1 master &&
+       echo "$test_name" >a1 &&
+       git add a1 &&
+       git commit -m "$test_name topic1 re #1" &&
+       git push origin topic1 &&
+
+       git checkout -b topic2 master &&
+       echo "$test_name" >a2 &&
+       git add a2 &&
+       git commit -m "$test_name topic2 re #2" &&
+       git push origin topic2 &&
+
+       git checkout topic1 &&
+       echo "$test_name" >>a1 &&
+       git commit -a -m "$test_name topic1 re #1 again" &&
+       git merge topic2 &&
+       git push
+'
+
+test_done
+
diff --git a/tests/t2002-server-pre-receive-trac-branches.sh b/tests/t2002-server-pre-receive-trac-branches.sh
deleted file mode 100644 (file)
index 3588124..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-test_description='server pre-receive trac 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-trac' 'pre-receive'
-
-test_expect_success 'reject new branch with bad message' '
-       git checkout -b topic1 master &&
-       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' '
-       git checkout -b topic2 master &&
-       echo $test_name >a &&
-       git commit --amend -m "$test_name re #3222" &&
-       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
-
diff --git a/tests/t2002-server-update-trac-branches.sh b/tests/t2002-server-update-trac-branches.sh
new file mode 100644 (file)
index 0000000..437dbe6
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+test_description='server update trac 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 'update-trac' 'update'
+
+test_expect_success 'reject new branch with bad message' '
+       git checkout -b topic1 master &&
+       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' '
+       git checkout -b topic2 master &&
+       echo $test_name >a &&
+       git commit --amend -m "$test_name re #3222" &&
+       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
+
diff --git a/tests/t2003-server-pre-receive-trac-merges.sh b/tests/t2003-server-pre-receive-trac-merges.sh
deleted file mode 100644 (file)
index 7d3180d..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-
-test_description='server pre-receive trac 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-trac' 'pre-receive'
-
-test_expect_success 'accept merge with merge message' '
-       git checkout -b topic1 master &&
-       echo "$test_name" >a1 &&
-       git add a1 &&
-       git commit -m "$test_name topic1 re #1" &&
-       git push origin topic1 &&
-
-       git checkout -b topic2 master &&
-       echo "$test_name" >a2 &&
-       git add a2 &&
-       git commit -m "$test_name topic2 re #2" &&
-       git push origin topic2 &&
-
-       git checkout topic1 &&
-       echo "$test_name" >>a1 &&
-       git commit -a -m "$test_name topic1 re #1 again" &&
-       git merge topic2 &&
-       git push
-'
-
-test_done
-