Clark
Clark

Reputation: 2213

Using PHP to write git hooks

I want to use PHP writing git hooks but have some problem. I use Windows 7 LAMP packet and git bash. So, if I run the next script (pre-commit hook) through git shell:

https://gist.github.com/713716

it works fine and there is 123 on the screen. But if I use:


git commit

I have the next error:


error: cannot spawn .git/hooks/pre-commit: No such file or directory

So, what the problem is?

Upvotes: 2

Views: 1902

Answers (1)

brycemcd
brycemcd

Reputation: 4513

I rarely work on Windows systems but it might have something to do with either making sure the pre-commit file is executable by every user (per Phil's comment), or something to do with git invoking a php command.

Looks like this problem may exist elsewhere but not easily reproduceable.

It's janky, but it might work if you create a new file somewhere with a php extension and invoke that file from the pre-commit hook.

#pre-commit
C:/WebServers/usr/local/php5/php C:/path/to/123.php
#123.php
<?php echo 123 ?>

Upvotes: 1

Related Questions