]> git.droids-corp.org - git-central.git/commitdiff
Show pre-receive-stable stopping following commands if used via a shim.
authorStephen Haberman <stephen@exigencecorp.com>
Fri, 20 Jun 2008 14:48:44 +0000 (09:48 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Fri, 20 Jun 2008 14:48:44 +0000 (09:48 -0500)
server/noop [new file with mode: 0644]
server/post-receive
server/pre-receive
server/pre-receive-stable-then-noop [new file with mode: 0644]
tests/t2101-server-pre-receive-stable-via-shim.sh [new file with mode: 0644]

diff --git a/server/noop b/server/noop
new file mode 100644 (file)
index 0000000..829303e
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+
index 80e3465543e1150b97a77cab9558a434f47efc0f..f345eed383cd86a2b0d59cb84617ece1306d353c 100644 (file)
@@ -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
 
index 25f6c233977c560bc5a23d60875ff8b4ec1b0467..5ed7e5c176a0df40cff55e19701989eb3eb7085b 100644 (file)
@@ -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 (file)
index 0000000..5ed7e5c
--- /dev/null
@@ -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 (file)
index 0000000..a457aed
--- /dev/null
@@ -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
+