From: Stephen Haberman Date: Fri, 20 Jun 2008 14:48:44 +0000 (-0500) Subject: Show pre-receive-stable stopping following commands if used via a shim. X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7399e44f6298a55a387b974cc1df1feb43c42588;p=git-central.git Show pre-receive-stable stopping following commands if used via a shim. --- diff --git a/server/noop b/server/noop new file mode 100644 index 0000000..829303e --- /dev/null +++ b/server/noop @@ -0,0 +1,3 @@ +#!/bin/sh + + diff --git a/server/post-receive b/server/post-receive index 80e3465..f345eed 100644 --- a/server/post-receive +++ b/server/post-receive @@ -8,6 +8,6 @@ while read line ; do input="$input$line" done -echo $input | sh hooks/post-receive-email -echo $input | sh hooks/post-receive-trac +echo $input | sh $GIT_DIR/hooks/post-receive-email +echo $input | sh $GIT_DIR/hooks/post-receive-trac diff --git a/server/pre-receive b/server/pre-receive index 25f6c23..5ed7e5c 100644 --- a/server/pre-receive +++ b/server/pre-receive @@ -1,4 +1,10 @@ #!/bin/sh -. $GIT_DIR/hooks/pre-receive-ticket +input="" +while read line ; do + input="$input$line" +done + +echo $input | sh $GIT_DIR/hooks/pre-receive-stable && +echo $input | sh $GIT_DIR/hooks/noop diff --git a/server/pre-receive-stable-then-noop b/server/pre-receive-stable-then-noop new file mode 100644 index 0000000..5ed7e5c --- /dev/null +++ b/server/pre-receive-stable-then-noop @@ -0,0 +1,10 @@ +#!/bin/sh + +input="" +while read line ; do + input="$input$line" +done + +echo $input | sh $GIT_DIR/hooks/pre-receive-stable && +echo $input | sh $GIT_DIR/hooks/noop + diff --git a/tests/t2101-server-pre-receive-stable-via-shim.sh b/tests/t2101-server-pre-receive-stable-via-shim.sh new file mode 100644 index 0000000..a457aed --- /dev/null +++ b/tests/t2101-server-pre-receive-stable-via-shim.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +test_description='server pre-receive stable 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 checkout -b stable && + git remote add origin ./server && + git push origin stable && + git config --add branch.stable.remote origin && + git config --add branch.stable.merge refs/heads/stable +' + +# setup the pre-receive hook +install_server_hook 'pre-receive-stable' 'pre-receive-stable' +install_server_hook 'noop' 'noop' +install_server_hook 'pre-receive-stable-then-noop' 'pre-receive' + +test_expect_success 'reject commit directly to stable' ' + echo $test_name >a && + git commit -a -m "$test_name going onto stable" && + head=$(git rev-parse HEAD) && + ! git push 2>push.err && + cat push.err | grep "Moving stable to $head includes a new commit" +' + +test_done +