經過進一步調查和測試,這裏是一個有效的解決方案:
創建文件.git/hooks/hook-chain
如下
#!/bin/bash
#
# author: orefalo
hookname=`basename $0`
FILE=`mktemp`
trap 'rm -f $FILE' EXIT
cat - > $FILE
for hook in $GIT_DIR/hooks/$hookname.*
do
if test -x "$hook"; then
# echo $hook
cat $FILE | $hook "[email protected]"
status=$?
if test $status -ne 0; then
echo Hook $hook failed with error code $status
exit $status
fi
fi
done
現在鏈接需要鏈接任何掛鉤,例如
最後,通過將它們重命名爲hookname
來創建鏈。 action
-rwxr-xr-x. 1 git git 6710 functions
-rwxr-xr-x. 1 git git 280 hook-chain
-rwxr-xr-x. 1 git git 1524 post-mirror
lrwxrwxrwx. 1 root root 10 post-receive -> hook-chain
-rwxr-xr-x. 1 git git 8763 post-receive.1email
-rwxr-xr-x. 1 git git 1745 post-receive.2github
-rwxr-xr-x. 1 git git 473 post-upload-pack
-rwxr-xr-x. 1 git git 346 pre-receive
lrwxrwxrwx. 1 root root 10 update -> hook-chain
-rwxr-xr-x. 1 git git 2975 update.1acl
-rwxr-xr-x. 1 git git 328 update.2github
例如,上面的示例中,所述更新鉤將運行update.1acl隨後update.2github。
的後收到鉤與運行後receive.1email隨後後receive.2github
相關答案:http://stackoverflow.com/a/3464399/119963有跟蹤的掛鉤,而不是鏈接它們,但鏈接基本上是一個平凡擴張的重點:一包循環執行鉤子程序(例如'hook for hooks/update.d/*; do ...') – Cascabel 2012-01-04 18:03:36
謝謝你的指針,它有幫助 – 2012-01-04 22:16:14