Multiple git hooks for the same trigger

三世轮回 提交于 2019-12-05 09:42:57

Sure. Create a wrapper post-checkout hook script that calls the other scripts:

#!/bin/sh

$GIT_DIR/hooks/my-tmux-post-checkout "$@"
$GIT_DIR/hooks/corporate-post-checkout "$@"

You could get fancier and iterate over an arbitrary number of scripts in a post-checkout.d directory or something, but the basic idea is the same.

Update for Steve

For scripts that expect input on stdin:

#!/bin/sh

tmpfile=$(mktemp hookXXXXXX)
trap "rm -f $tmpfile" EXIT
cat > $tmpfile

$GIT_DIR/hooks/my-tmux-post-checkout "$@" < $tmpfile
$GIT_DIR/hooks/corporate-post-checkout "$@" < $tmpfile

This should actually be harmless to use for the first case as well, although if you test it by running it manually you would need to make sure you always redirect stdin from somewhere (possibly /dev/null).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!