Skip to content

chore: fix the pre-commit hook - #314

Merged
vitgrams merged 4 commits into
masterfrom
chore/composer-check-script
Nov 11, 2026
Merged

vitgrams merged 4 commits into
masterfrom
chore/composer-check-script

Conversation

@DenTray

@DenTray DenTray commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Why.
The pre-commit hook configured in extra.hooks was never installed: composer-git-hooks is a plain library, so the hook reaches .git/hooks only through cghooks add, and nothing called it. If installed by hand it would fail: docker-compose.yml has no php service, tlint is not a dependency, and php-cs-fixer fix disagrees with Pint (which CI uses since ea43d8e) on 3 files and leaves its fixes unstaged.

What changed.

  • The hook runs the same Pint check as CI inside the project image: docker-compose run --rm -T nginx vendor/bin/pint --test, so no local PHP is needed.
  • post-install-cmd / post-update-cmd install and update the hook through cghooks; both skip it on --no-dev installs, where cghooks is absent.

Verification.

  • composer validate passes (only the existing warning about the unbound laravel/framework constraint).
  • The hook command exits 0 on the current code and 1 on a file with a style violation (~7 s per run).
  • composer run-script --no-dev post-install-cmd exits 0 with the guard and fails with code 127 without it.

🤖 Generated with Claude Code

The pre-commit hook called docker-compose, php-cs-fixer and tlint (not a
dependency) and was never installed. It now runs `composer lint`, the same
Pint check CI runs, and cghooks installs it on composer install/update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bb92e5e11

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread composer.json Outdated
Comment on lines +69 to +70
"post-install-cmd": "cghooks add --ignore-lock",
"post-update-cmd": "cghooks update"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard hook setup during no-dev installs

When this repository is installed or updated with --no-dev, these event handlers still execute after Composer has omitted brainmaestro/composer-git-hooks, so cghooks is absent from PATH and the Composer command exits nonzero. This breaks clean dependency-only installations; Composer confirms that --no-dev prevents dev requirements from being installed, and the package maintainer recommends checking whether the binary exists before invoking it in these events in the upstream discussion. Guard both handlers when cghooks is unavailable.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f33175: both handlers now start with [ $COMPOSER_DEV_MODE -eq 0 ] ||, so --no-dev installs skip cghooks and exit 0, while dev installs still set up the hook.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T10:20:18.081698Z ec09060 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f33175b8d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread composer.json
Comment on lines +69 to +70
"post-install-cmd": "[ $COMPOSER_DEV_MODE -eq 0 ] || cghooks add --ignore-lock",
"post-update-cmd": "[ $COMPOSER_DEV_MODE -eq 0 ] || cghooks update"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a cross-platform dev-mode guard

On native Windows, both lifecycle handlers fail before hook setup because [ and $COMPOSER_DEV_MODE are POSIX-shell syntax rather than cmd.exe syntax. Composer executes string scripts through Process::fromShellCommandline and explicitly uses Windows command handling (Composer ProcessExecutor), so every composer install or composer update on Windows exits nonzero, including --no-dev runs. Use a PHP callback or another cross-platform guard instead.

Useful? React with 👍 / 👎.

DenTray and others added 2 commits November 11, 2026 16:11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DenTray DenTray changed the title chore: add composer check script and fix the pre-commit hook chore: fix the pre-commit hook Nov 11, 2026
@DenTray
DenTray requested a review from vitgrams November 11, 2026 10:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec0906064d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread composer.json
]
}
},
"scripts": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add the missing check script

The new scripts map contains only lifecycle handlers, so the advertised composer check command never runs Pint or PHPUnit. With Composer 2.9.7, composer help check instead resolves check to the built-in check-platform-reqs command (described as “Check that platform requirements are satisfied”), meaning the command can report success while formatting or tests fail; restore the lint, test, and composed check entries.

Useful? React with 👍 / 👎.

@vitgrams
vitgrams merged commit 073eafe into master Nov 11, 2026
9 checks passed
@vitgrams
vitgrams deleted the chore/composer-check-script branch November 11, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants