异步git hook?

obe*_*msi 11 git githooks

我在post-receive上执行单元测试但不希望用户等待它.

我尝试了git-user邮件列表中的建议("只是&它"),但这不起作用:https://groups.google.com/forum/#!topic / git-users/CFshrDgYYzE

即使我把它放在hooks/post-receive中,git似乎还在等待bash脚本退出:

exec-unit-tests.sh &
Run Code Online (Sandbox Code Playgroud)

obe*_*msi 20

这对我有用.&并且必须关闭stdout和stderr管道:

long-running-command >&- 2>&- & 
Run Code Online (Sandbox Code Playgroud)

为了将命令放在后台,必须关闭两个stdoutAND stderr.如果它们中的任何一个处于打开状态,则进程将不在后台,并且在钩子脚本完成之前,提交操作将不会完成.

懒惰的另一种方法是简单地重定向stdoutstderr/dev/null:

long-running-command >/dev/null 2>&1 & 
Run Code Online (Sandbox Code Playgroud)

这有点不太干净,但也许更容易理解和记忆,并且它具有相同的效果.