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
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"
+++ /dev/null
-#!/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
-
+++ /dev/null
-#!/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
-
--- /dev/null
+#!/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
+
+++ /dev/null
-#!/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
-
--- /dev/null
+#!/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
+
+++ /dev/null
-#!/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
-
--- /dev/null
+#!/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
+
+++ /dev/null
-#!/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
-
--- /dev/null
+#!/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
+
+++ /dev/null
-#!/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
-