From: Stephen Haberman Date: Sun, 13 Jul 2008 21:49:31 +0000 (-0500) Subject: Use permanent shims as the test hook scripts. Not used by all the tests yet. X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2e7436eabab624c69e1925f0ae11115b8816d00c;p=git-central.git Use permanent shims as the test hook scripts. Not used by all the tests yet. --- diff --git a/tests/t2100-server-update-stable.sh b/tests/t2100-server-update-stable.sh index 0961b99..1364f5b 100644 --- a/tests/t2100-server-update-stable.sh +++ b/tests/t2100-server-update-stable.sh @@ -14,7 +14,7 @@ test_expect_success 'setup' ' ' # setup the update hook -install_server_hook 'update-stable' 'update' +install_update_hook 'update-stable' test_expect_success 'initial stable commit works', ' # do one stable-less commit diff --git a/tests/t2200-server-post-receive-email.sh b/tests/t2200-server-post-receive-email.sh index c49ad53..2ac0dcb 100644 --- a/tests/t2200-server-post-receive-email.sh +++ b/tests/t2200-server-post-receive-email.sh @@ -19,7 +19,7 @@ test_expect_success 'setup' ' echo cbas >./server/.git/description ' -install_server_hook 'post-receive-email' 'post-receive' +install_post_receive_hook 'post-receive-email' test_expect_success 'simple commit' ' echo $test_name >a && diff --git a/tests/t2201-server-post-receive-email-tags.sh b/tests/t2201-server-post-receive-email-tags.sh index ed823da..4e0e0f3 100644 --- a/tests/t2201-server-post-receive-email-tags.sh +++ b/tests/t2201-server-post-receive-email-tags.sh @@ -19,7 +19,7 @@ test_expect_success 'setup' ' echo cbas >./server/.git/description ' -install_server_hook 'post-receive-email' 'post-receive' +install_post_receive_hook 'post-receive-email' test_expect_success 'create tag' ' git tag -a -m 1.0 1.0 && diff --git a/tests/t2202-server-post-receive-email-branches.sh b/tests/t2202-server-post-receive-email-branches.sh index ad34ad2..0b35c61 100644 --- a/tests/t2202-server-post-receive-email-branches.sh +++ b/tests/t2202-server-post-receive-email-branches.sh @@ -19,7 +19,7 @@ test_expect_success 'setup' ' echo cbas >./server/.git/description ' -install_server_hook 'post-receive-email' 'post-receive' +install_post_receive_hook 'post-receive-email' test_expect_success 'create branch' ' git checkout -b topic master && diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 9d35ad6..f88ad66 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -462,12 +462,34 @@ install_server_hook () { install_update_hook () { mkdir -p "server/.git/hooks" hook="server/.git/hooks/update" - chmod +x $hook echo "#!/bin/sh" >$hook for ((i=1;i<=$#;i+=1)); do eval script_name="$"$i echo "../../../../server/$script_name \$1 \$2 \$3" >>$hook done + + chmod +x $hook +} + +install_post_receive_hook () { + mkdir -p "server/.git/hooks" + hook="server/.git/hooks/post-receive" + + cat >$hook <<-'EOF' + #!/bin/sh + nl=$'\n' + input="" + while read newref oldref refname ; do + input="$input$newref $oldref $refname$nl" + done + EOF + + for ((i=1;i<=$#;i+=1)); do + eval script_name="$"$i + echo "echo -n \"\$input\" | ../../../../server/$script_name" >>$hook + done + + chmod +x $hook }