From 91cc9799a6ef491a91e581f41d086f3e5f2b1a2e Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Thu, 19 Jun 2008 20:29:58 -0500 Subject: [PATCH] Test using the pre-receive -> pre-receive-ticket shim. --- server/pre-receive | 4 ++ tests/t2000-server-pre-receive-ticket.sh | 6 +-- ...2001-server-pre-receive-ticket-via-shim.sh | 39 +++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 server/pre-receive create mode 100644 tests/t2001-server-pre-receive-ticket-via-shim.sh diff --git a/server/pre-receive b/server/pre-receive new file mode 100644 index 0000000..25f6c23 --- /dev/null +++ b/server/pre-receive @@ -0,0 +1,4 @@ +#!/bin/sh + +. $GIT_DIR/hooks/pre-receive-ticket + diff --git a/tests/t2000-server-pre-receive-ticket.sh b/tests/t2000-server-pre-receive-ticket.sh index b84dca5..7c5c5d3 100644 --- a/tests/t2000-server-pre-receive-ticket.sh +++ b/tests/t2000-server-pre-receive-ticket.sh @@ -21,16 +21,16 @@ 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 + 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 "foo re #3222" && + git commit --amend -m "$test_name re #3222" && git push ' diff --git a/tests/t2001-server-pre-receive-ticket-via-shim.sh b/tests/t2001-server-pre-receive-ticket-via-shim.sh new file mode 100644 index 0000000..6a99ba6 --- /dev/null +++ b/tests/t2001-server-pre-receive-ticket-via-shim.sh @@ -0,0 +1,39 @@ + +#!/bin/sh + +test_description='server pre-receive ticket enforcer via shim' + +. ./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 shim +install_server_hook 'pre-receive' 'pre-receive' +install_server_hook 'pre-receive-ticket' 'pre-receive-ticket' + +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_done + -- 2.39.5