]> git.droids-corp.org - git-central.git/commitdiff
Only one branch push/recive.
authorStephen Haberman <stephen@exigencecorp.com>
Sat, 21 Jun 2008 16:19:29 +0000 (11:19 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Sat, 21 Jun 2008 16:19:29 +0000 (11:19 -0500)
server/pre-receive-only-one [new file with mode: 0644]
tests/t2400-server-pre-receive-only-one.sh [new file with mode: 0644]

diff --git a/server/pre-receive-only-one b/server/pre-receive-only-one
new file mode 100644 (file)
index 0000000..819167a
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+i=0
+while read oldrev newrev refname ; do
+       i=$(($i + 1))
+done
+
+if [ $i -ne 1 ] ; then
+       echo "----------------------------------------------------"
+       echo
+       echo "Only push one branch at a time"
+       echo
+       echo "----------------------------------------------------"
+       exit 1
+fi
+
diff --git a/tests/t2400-server-pre-receive-only-one.sh b/tests/t2400-server-pre-receive-only-one.sh
new file mode 100644 (file)
index 0000000..8a07a9f
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+test_description='server pre-receive only one branch/push'
+
+. ./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 &&
+       git fetch
+'
+
+install_server_hook 'pre-receive-only-one' 'pre-receive'
+
+test_expect_success 'pushing just topic is okay' '
+       git checkout -b topic &&
+       echo "$test_name" >a &&
+       git commit -a -m "$test_name on topic" &&
+       git push origin topic
+'
+
+test_expect_success 'pushing just master is okay' '
+       git checkout master &&
+       echo "$test_name" >a &&
+       git commit -a -m "$test_name on master" &&
+       git push
+'
+
+test_expect_success 'pushing both master and topic fails' '
+       echo "$test_name" >a &&
+       git commit -a -m "$test_name on master" &&
+
+       git checkout topic &&
+       echo "$test_name" >a &&
+       git commit -a -m "$test_name on topic" &&
+
+       ! git push 2>push.err &&
+       cat push.err | grep "Only push one branch at a time"
+'
+
+
+test_done
+