我想用 PHP 编写 git hooks 但有一些问题。
我使用 Windows 7 LAMP 数据包和 git bash。
因此,如果我通过 git shell 运行下一个脚本(预提交 Hook ):
https://gist.github.com/713716
它工作正常,屏幕上有123。但如果我使用:
git commit
我有下一个错误:
error: cannot spawn .git/hooks/pre-commit: No such file or directory
那么,问题是什么?
最佳答案
我很少在 Windows 系统上工作,但这可能与确保预提交文件可由每个用户执行(根据 Phil 的评论)或与 git 调用 php 命令有关。
看起来像 this problem may exist elsewhere but not easily reproduceable .
这很麻烦,但如果您在某处创建一个带有 php 扩展名的新文件并从 pre-commit Hook 调用该文件,它可能会起作用。
#pre-commit
C:/WebServers/usr/local/php5/php C:/path/to/123.php
#123.php
<?php echo 123 ?>
关于php - 使用 PHP 编写 git hooks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4267817/