Fix git hook GrumPHP command resolution for global installs#332
Conversation
5084336 to
399cbb2
Compare
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughSummary by CodeRabbit
WalkthroughUpdates packaged git hooks to prefer ChangesResilient GrumPHP binary resolution in git hooks
Remove strict prepared set from ECSConfig defaults
Wiki subproject reference update
Sequence Diagram(s)sequenceDiagram
participant HookScript
participant Selector as GRUMPHP_COMMAND_Selector
participant GrumPHP as GrumPHP_Executable
participant Git as Git_Target
HookScript->>Selector: check vendor/bin/grumphp -> vendor/bin/grumphp.phar -> grumphp
Selector->>HookScript: export GRUMPHP_COMMAND
HookScript->>GrumPHP: printf "%s\n" "${DIFF}" | exec "${GRUMPHP_COMMAND}" git:<hook> [--config args]
GrumPHP->>Git: execute git:<hook> target
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
💡 Codex ReviewLines 29 to 31 in 5084336 When the global binary runs inside a project, this script loads the project autoloader first, then unconditionally calls ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
5084336 to
322b9fa
Compare
|
🚀 Preview is available for this pull request. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 322b9fa17a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [ -n "${GRUMPHP_CONFIG_FILE}" ]; then | ||
| printf "%s\n" "${DIFF}" | exec "${GRUMPHP_COMMAND}" '--config' "${GRUMPHP_CONFIG_FILE}" 'git:pre-commit' '--skip-success-output' | ||
| fi | ||
|
|
||
| printf "%s\n" "${DIFF}" | exec "${GRUMPHP_COMMAND}" 'git:pre-commit' '--skip-success-output' |
There was a problem hiding this comment.
Avoid unconditional second pre-commit GrumPHP execution
After the configured invocation runs, the script always falls through to a second git:pre-commit call without --config. In environments where /bin/sh executes pipeline segments in subshells (common with dash/bash), the first exec does not terminate the parent script, so this second call still runs and can fail when the default config is absent (a typical global-install case), causing commits to be blocked even though the configured run succeeded.
Useful? React with 👍 / 👎.
Closes #331
Summary
GrumPHP is sniffing your code!
! [NOTE] Running testsuite: git_pre_commit
Running tasks with priority 0!
Running task 1/5: composer_script...
Running task 2/5: composer...
Running task 3/5: phplint...
Running task 4/5: jsonlint...
Running task 5/5: yamllint...
Running task 1/5: composer_script...
Running task 2/5: composer...
Running task 3/5: phplint...
Running task 4/5: jsonlint...
Running task 5/5: yamllint...
GrumPHP detected a pre-commit command.
GrumPHP is sniffing your code!
! [NOTE] Running testsuite: git_pre_commit
Running tasks with priority 0!
Running task 1/5: composer_script...
Running task 2/5: composer...
Running task 3/5: phplint...
Running task 4/5: jsonlint...
Running task 5/5: yamllint...
Running task 1/5: composer_script...
Running task 2/5: composer...
Running task 3/5: phplint...
Running task 4/5: jsonlint...
Running task 5/5: yamllint... , ) to avoid hardcoded GrumPHP 2.20.0
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
--silent Do not output any message
-q, --quiet Only errors are displayed. All other output is suppressed
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-c, --config=CONFIG Path to config
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
completion Dump the shell completion script
configure Create a grumphp configuration file
help Display help for a command
list List commands
run Run configured tasks
git
git:commit-msg Executed by the commit-msg commit hook
git:deinit Removes the commit hooks
git:init Registers the Git hooks
git:pre-commit Executed by the pre-commit hook.
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
--silent Do not output any message
-q, --quiet Only errors are displayed. All other output is suppressed
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-c, --config=CONFIG Path to config
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
completion Dump the shell completion script
configure Create a grumphp configuration file
help Display help for a command
list List commands
run Run configured tasks
git
git:commit-msg Executed by the commit-msg commit hook
git:deinit Removes the commit hooks
git:init Registers the Git hooks
git:pre-commit Executed by the pre-commit hook -> GrumPHP 2.20.0
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
--silent Do not output any message
-q, --quiet Only errors are displayed. All other output is suppressed
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-c, --config=CONFIG Path to config
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
completion Dump the shell completion script
configure Create a grumphp configuration file
help Display help for a command
list List commands
run Run configured tasks
git
git:commit-msg Executed by the commit-msg commit hook
git:deinit Removes the commit hooks
git:init Registers the Git hooks
git:pre-commit Executed by the pre-commit hook -> GrumPHP 2.20.0
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
--silent Do not output any message
-q, --quiet Only errors are displayed. All other output is suppressed
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-c, --config=CONFIG Path to config
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
completion Dump the shell completion script
configure Create a grumphp configuration file
help Display help for a command
list List commands
run Run configured tasks
git
git:commit-msg Executed by the commit-msg commit hook
git:deinit Removes the commit hooks
git:init Registers the Git hooks
git:pre-commit Executed by the pre-commit hook in PATH.
Context
This is an intermediate stabilization step before implementing #296 (Git hook extraction into dedicated package).