I'm trying to create a pre-push
hook to run php-cs-fixer
before every push.
This is the current pre-push
hook I have:
#!/bin/sh
exec php-cs-fixer fix . --config-file=".php_cs" && git commit -am 'PSR-2'
The first command gets trigger without a problem.
Only the git commit -am 'PSR-2
doesn't. To be more precise, the php-cs-fixer
runs followed by this error error: failed to push some refs to ..
I also tried the following without luck:
#!/bin/sh
php-cs-fixer fix . --config-file=".php_cs" && git commit -am 'PSR-2'
-
#!/bin/sh
(php-cs-fixer fix . --config-file=".php_cs" && git commit -am 'PSR-2')
According to this stackoverflow question, it should run only if cmd1 has succeeded.