git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $newrev
else
git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $oldrev..$newrev
- fi | while read com ; do
- /home/BIPFS/shaberman/local/bin/python /srv/git/hooks/trac-post-commit-hook.py -p "$TRAC_ENV" -r "$com"
+ fi | while read commit ; do
+ /home/BIPFS/shaberman/local/bin/python /srv/git/hooks/trac-post-commit-hook.py -p "$TRAC_ENV" -r "$commit"
done
done
--- /dev/null
+#!/bin/sh
+
+while read oldrev newrev refname ; do
+ if expr "$oldrev" : '0*$' >/dev/null
+ then
+ git rev-list $newrev
+ else
+ git rev-list $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
+done
+
--- /dev/null
+
+#!/bin/sh
+
+test_description='server pre-receive 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-ticket' 'pre-receive'
+
+test_expect_success 'reject with bad message' '
+ echo $test_name >a &&
+ git commit -a -m "foo" &&
+ git push >push.out 2>push.err
+ head=$(git rev-parse HEAD)
+ 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 "foo 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_done
+
chmod +x "$TRASH_HOOKS/$2"
}
+install_server_hook () {
+ mkdir -p "server/.git/hooks"
+ cp "../../server/$1" "server/.git/hooks/$2"
+ chmod +x "server/.git/hooks/$2"
+}
+