From 2a6f662710be532e1960fffff8d6b8347f410853 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Tue, 24 Jun 2008 12:47:30 -0500 Subject: [PATCH] Convert stable to update. --- cbas/pre-receive | 3 +- cbas/update | 3 +- server/pre-receive-stable | 29 ---------------- server/pre-receive-stable-then-noop | 10 ------ server/update-stable | 31 +++++++++++++++++ ...table.sh => t2100-server-update-stable.sh} | 6 ++-- ...2101-server-pre-receive-stable-via-shim.sh | 34 ------------------- 7 files changed, 37 insertions(+), 79 deletions(-) delete mode 100644 server/pre-receive-stable delete mode 100644 server/pre-receive-stable-then-noop create mode 100644 server/update-stable rename tests/{t2100-server-pre-receive-stable.sh => t2100-server-update-stable.sh} (93%) delete mode 100644 tests/t2101-server-pre-receive-stable-via-shim.sh diff --git a/cbas/pre-receive b/cbas/pre-receive index 800f366..a0684d8 100755 --- a/cbas/pre-receive +++ b/cbas/pre-receive @@ -6,6 +6,5 @@ while read newref oldref refname ; do input="$input$newref $oldref $refname$nl" done -echo -n "$input" | sh /srv/git/hooks/server/pre-receive-only-one && -echo -n "$input" | sh /srv/git/hooks/server/pre-receive-stable +echo -n "$input" | sh /srv/git/hooks/server/pre-receive-only-one diff --git a/cbas/update b/cbas/update index baa1bdb..885aff4 100755 --- a/cbas/update +++ b/cbas/update @@ -6,5 +6,6 @@ newrev="$3" sh /srv/git/hooks/server/update-trac "$refname" "$oldrev" "$newrev" && sh /srv/git/hooks/server/update-allow-tags-branches "$refname" "$oldrev" "$newrev" && -sh /srv/git/hooks/server/update-prefer-rebase "$refname" "$oldrev" "$newrev" +sh /srv/git/hooks/server/update-prefer-rebase "$refname" "$oldrev" "$newrev" && +sh /srv/git/hooks/server/update-stable "$refname" "$oldrev" "$newrev" diff --git a/server/pre-receive-stable b/server/pre-receive-stable deleted file mode 100644 index 7e2fd60..0000000 --- a/server/pre-receive-stable +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -while read oldrev newrev refname ; do - if expr "$oldrev" : '0*$' >/dev/null ; then - exit 0 - fi - - if [ "$refname" != "refs/heads/stable" ] ; then - exit 0 - fi - - # read backwards: - # - all commits from old..new - # - unless they were already pointed to by a branch - # - unless that branch is us - # = all new commits on stable - count=$(git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $oldrev..$newrev | wc -l) - if [ "$count" -ne "0" ] ; then - newname=$(git rev-parse "$newrev") - echo "----------------------------------------------------" - echo - echo "Moving stable to $newname includes a new commit" - echo - echo "----------------------------------------------------" - exit 1 - fi -done - - diff --git a/server/pre-receive-stable-then-noop b/server/pre-receive-stable-then-noop deleted file mode 100644 index 5ed7e5c..0000000 --- a/server/pre-receive-stable-then-noop +++ /dev/null @@ -1,10 +0,0 @@ -#!/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/server/update-stable b/server/update-stable new file mode 100644 index 0000000..416495c --- /dev/null +++ b/server/update-stable @@ -0,0 +1,31 @@ +#!/bin/sh + +# Command line +refname="$1" +oldrev="$2" +newrev="$3" + +if expr "$oldrev" : '0*$' >/dev/null ; then + exit 0 +fi + +if [ "$refname" != "refs/heads/stable" ] ; then + exit 0 +fi + +# read backwards: +# - all commits from old..new +# - unless they were already pointed to by a branch +# = all new commits on stable +count=$(git rev-parse --not --branches | git rev-list --stdin $oldrev..$newrev | wc -l) +if [ "$count" -ne "0" ] ; then + newname=$(git rev-parse "$newrev") + echo "----------------------------------------------------" + echo + echo "Moving stable to $newname includes a new commit" + echo + echo "----------------------------------------------------" + exit 1 +fi + + diff --git a/tests/t2100-server-pre-receive-stable.sh b/tests/t2100-server-update-stable.sh similarity index 93% rename from tests/t2100-server-pre-receive-stable.sh rename to tests/t2100-server-update-stable.sh index 029f574..32dd039 100644 --- a/tests/t2100-server-pre-receive-stable.sh +++ b/tests/t2100-server-update-stable.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='server pre-receive stable enforcer' +test_description='server update stable enforcer' . ./test-lib.sh @@ -17,8 +17,8 @@ test_expect_success 'setup' ' git config --add branch.stable.merge refs/heads/stable ' -# setup the pre-receive hook -install_server_hook 'pre-receive-stable' 'pre-receive' +# setup the update hook +install_server_hook 'update-stable' 'update' test_expect_success 'reject commit directly to stable' ' echo $test_name >a && diff --git a/tests/t2101-server-pre-receive-stable-via-shim.sh b/tests/t2101-server-pre-receive-stable-via-shim.sh deleted file mode 100644 index a457aed..0000000 --- a/tests/t2101-server-pre-receive-stable-via-shim.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/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 - -- 2.39.5