'
# 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
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 &&
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 &&
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 &&
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
}