From 4365350d5362d0aa336e64f47eace7007604ce3b Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Thu, 14 Aug 2008 10:51:30 -0500 Subject: [PATCH] Add excused to ensure follows. --- server/update-ensure-follows | 26 +++++++++++++++-------- tests/t2700-server-ensure-follows.sh | 31 +++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/server/update-ensure-follows b/server/update-ensure-follows index eedfa8a..2d5ef08 100644 --- a/server/update-ensure-follows +++ b/server/update-ensure-follows @@ -15,7 +15,7 @@ oldrev="$2" newrev="$3" # Look up the config variable and exit if not set -follows=$(git config hooks.ensure-follows) +follows=$(git config hooks.update-ensure-follows.branches) if [[ $? -ne 0 ]] ; then exit 0 fi @@ -35,18 +35,26 @@ case "$refname" in ;; esac +excused=" $(git config hooks.update-ensure-follows.excused) " +if [[ $excused =~ " $short_refname " ]] ; then + exit 0 +fi + follows=($follows) count=${#follows[@]} for ((i = 0 ; i < count ; i++)) do follow="${follows[$i]}" - missing_commits=$(git log ^$newrev $follow --pretty=oneline | wc -l) - if [ $missing_commits -ne 0 ] ; then - echo "----------------------------------------------------" - echo - echo "You need to merge $follow into $short_refname" - echo - echo "----------------------------------------------------" - exit 1 + git rev-parse "$follow" + if [ $? -eq 0 ] ; then + missing_commits=$(git log ^$newrev $follow --pretty=oneline | wc -l) + if [ $missing_commits -ne 0 ] ; then + echo "----------------------------------------------------" + echo + echo "You need to merge $follow into $short_refname" + echo + echo "----------------------------------------------------" + exit 1 + fi fi done diff --git a/tests/t2700-server-ensure-follows.sh b/tests/t2700-server-ensure-follows.sh index b456525..a5eb1fa 100644 --- a/tests/t2700-server-ensure-follows.sh +++ b/tests/t2700-server-ensure-follows.sh @@ -25,7 +25,7 @@ test_expect_success 'pushing stable works' ' test_expect_success 'branch with unmoved stable is okay' ' cd server && - git config hooks.ensure-follows stable && + git config hooks.update-ensure-follows.branches stable && cd .. && git checkout -b topic1 && @@ -53,7 +53,7 @@ test_expect_success 'branch with moved stable requires merge' ' test_expect_success 'branch with moved stable as second branch requires merge' ' cd server && - git config hooks.ensure-follows "foo stable" && + git config hooks.update-ensure-follows.branches "foo stable" && cd .. && git checkout stable && @@ -86,7 +86,32 @@ test_expect_success 'branch deletion with moved stable is okay' ' git checkout stable && echo "$test_name" >a && git commit -a -m "Change on stable" && - git push origin :stable + + git push origin :topic1 +' + +test_expect_success 'excused branch with moved stable is okay' ' + git checkout -b topic2 stable && + echo "$test_name" >a.topic2 && + git add a.topic2 && + git commit -m "Change on topic2" && + git push origin topic2 && + + git checkout stable && + echo "$test_name" >a && + git commit -a -m "Change on stable" && + git push origin stable && + + git checkout topic2 && + echo "$test_name foo" >a.topic2 && + git commit -a -m "Change on topic2 again" && + ! git push origin topic2 && + + cd server && + git config hooks.update-ensure-follows.excused topic2 && + cd .. && + + git push origin topic2 ' test_done -- 2.39.5