grumphp: Bug in pre-commit hook (Gitonomy\Git\Exception\RuntimeException, Unable to find)
Hook:
$ /bin/sh
$ cat ./.git/hooks/pre-commit
#!/bin/sh
#
# Run the hook command.
# Note: this will be replaced by the real command during copy.
#
# Fetch the GIT diff and format it as command input:
DIFF=$(git diff -r -p -m -M --full-index --staged | cat)
echo $DIFF;
echo "";
# Run GrumPHP
(cd "./" && echo "${DIFF}" | exec 'vendor/phpro/grumphp/bin/grumphp' 'git:pre-commit' '--skip-success-output')
# Validate exit code of above command
RC=$?
if [ "$RC" != 0 ]; then
exit $RC;
fi
# Clean exit:
exit 0;
$ ./.git/hooks/pre-commit
diff --git a/demo/config/processor.php b/demo/config/processor.php index 9c2398bc43d2d5b39e31a4bb6c759848ccbb02ac..a740c15e751cdce83fc9aa20c14be7eeb2dd9ed2 100644 --- a/demo/config/processor.php +++ b/demo/config/processor.php @@ -5,7 +5,7 @@ namespace MailRu\QueueProcessor\Demo
[Gitonomy\Git\Exception\RuntimeException]
Unable to find "
"
git:pre-commit [--skip-success-output] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-c|--config [CONFIG]] [--] <command>
It cuts diff:
$ git diff -r -p -m -M --full-index --staged | cat
diff --git a/demo/config/processor.php b/demo/config/processor.php
index 9c2398bc43d2d5b39e31a4bb6c759848ccbb02ac..a740c15e751cdce83fc9aa20c14be7eeb2dd9ed2 100644
--- a/demo/config/processor.php
+++ b/demo/config/processor.php
@@ -5,7 +5,7 @@ namespace MailRu\QueueProcessor\Demo\config;
return [
'testPool' => [
'servers' => [
- 'mougrim-1215N',
+ php_uname('n'),
],
'maxWorkersQty' => 2,
'queues' => [
diff --git a/demo/shared/logs/.gitignore b/demo/shared/logs/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..72e8ffc0db8aad71a934dd11e5968bd5109e54b4
--- /dev/null
+++ b/demo/shared/logs/.gitignore
@@ -0,0 +1 @@
+*
bash output:
$ bash -c 'echo $(git diff -r -p -m -M --full-index --staged | cat); echo "" '
diff --git a/demo/config/processor.php b/demo/config/processor.php index 9c2398bc43d2d5b39e31a4bb6c759848ccbb02ac..a740c15e751cdce83fc9aa20c14be7eeb2dd9ed2 100644 --- a/demo/config/processor.php +++ b/demo/config/processor.php @@ -5,7 +5,7 @@ namespace MailRu\QueueProcessor\Demo\config; return [ 'testPool' => [ 'servers' => [ - 'mougrim-1215N', + php_uname('n'), ], 'maxWorkersQty' => 2, 'queues' => [ diff --git a/demo/shared/logs/.gitignore b/demo/shared/logs/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..72e8ffc0db8aad71a934dd11e5968bd5109e54b4 --- /dev/null +++ b/demo/shared/logs/.gitignore @@ -0,0 +1 @@ +*
sh output:
$ sh -c 'echo $(git diff -r -p -m -M --full-index --staged | cat); echo "" '
diff --git a/demo/config/processor.php b/demo/config/processor.php index 9c2398bc43d2d5b39e31a4bb6c759848ccbb02ac..a740c15e751cdce83fc9aa20c14be7eeb2dd9ed2 100644 --- a/demo/config/processor.php +++ b/demo/config/processor.php @@ -5,7 +5,7 @@ namespace MailRu\QueueProcessor\Demo
I think, problem is with “\c”:
$ bash -c 'echo "qwe\cqwe";echo ""'
qwe\cqwe
$ sh -c 'echo "qwe\cqwe";echo ""'
qwe
It’s reporoducing in Ubuntu 14.04 for pre-commit and commit-msg hooks in master: https://github.com/phpro/grumphp/blob/master/resources/hooks/local/pre-commit https://github.com/phpro/grumphp/blob/master/resources/hooks/local/commit-msg
I don’t try resources/hooks/vagrant/pre-commit and resources/hooks/vagrant/commit-msg.
I think fix is change #!/bin/sh to #!/bin/bash
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (8 by maintainers)
It requires
composer/composerwhich isn’t in the master branch of my personal github account since it’s outdated. Youo’ll have to change dev-master to the actual branch:dev-feature-escape-special-chars-in-diffCan you guys verify if this commit works for you so that I can merge it in? https://github.com/phpro/grumphp/pull/168
Thanks!