我想调用位于存储库中的脚本。
我当然可以执行以下操作:
#!/bin/sh
../../myscript.sh
但我认为这不太好;)
那么如何在提交后脚本中获取项目的路径呢?
When you're dealing with a non-bare repository, the post-commit
1 hook is run with a current working directory of the working tree of the repository. So, you don't need the ../../
.
如果您想要脚本的完整路径,您可以随时执行以下操作:
SCRIPT=$(readlink -nf myscript.sh)
...或者你可以使用git rev-parse --show-toplevel
获取工作目录的绝对路径:
SCRIPT=$(git rev-parse --show-toplevel)/myscript.sh
1 ... but note that this is not true of some other hooks, e.g. in a post-receive
hook in a non-bare repository, the current working directory is the .git
directory.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)