php - 使用 PHP 编写 git hooks

标签 php windows git hook

我想用 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/

相关文章:

php - Laravel 在 Controller 中划分并在 Blade 中显示

windows - 如何从 .cer 和 .key 获取 .pfx 文件?

c++ - GetProcessMemoryInfo 失败,错误 6 句柄无效

git - 报告的版本控制 (git)

php - 包含具有相同变量名的文件

php - 在 Linux 上获取当前配置的网络接口(interface)信息的问题

php - 如何在不指定索引号的情况下在 PHP 中构建对象数组?

xml - 将 xml 从一个文件夹移动到另一个文件夹时出错。字母之间为空

git - 将参数传递给 git post-receive Hook

git - 初始化 git repo 时 --bare 开关有什么区别?