Skip to content

[git-hooks] Handle drifted hook replacement safely (#190)#196

Merged
coisa merged 3 commits intomainfrom
codex/190-copy-resource-mode
Apr 24, 2026
Merged

[git-hooks] Handle drifted hook replacement safely (#190)#196
coisa merged 3 commits intomainfrom
codex/190-copy-resource-mode

Conversation

@coisa
Copy link
Copy Markdown
Contributor

@coisa coisa commented Apr 24, 2026

Related Issue

Closes #190

Motivation / Context

  • dev-tools:sync could fail during git-hooks when a drifted hook target in .git/hooks was left in an unwritable or otherwise broken state
  • the previous chmod call also used the wrong numeric form, which could leave hooks with invalid permissions

Changes

  • remove an existing drifted hook before copying the packaged replacement
  • keep hook install failures isolated per file and return a clear command failure after processing the full hook set
  • apply the executable mode with 0o755
  • document the defensive rewrite behavior and failure mode in the git-hooks command docs

Verification

  • composer dev-tools
  • Focused command(s):
    • composer dev-tools changelog:check
    • ./vendor/bin/phpunit tests/Console/Command/GitHooksCommandTest.php
  • Manual verification:
    • removed .git/hooks in this repository
    • ran php bin/dev-tools git-hooks --source=resources/git-hooks --target=.git/hooks
    • verified ls -lash .git/hooks and stat showed -rwxr-xr-x for installed hooks

Documentation / Generated Output

  • README updated
  • docs/ updated
  • Generated or synchronized output reviewed

Changelog

  • Added a notable CHANGELOG.md entry

Reviewer Notes

  • .github/wiki remains a local-only change in my checkout and is intentionally not part of this PR.

@github-actions
Copy link
Copy Markdown
Contributor

@coisa coisa merged commit b30fc34 into main Apr 24, 2026
30 checks passed
@coisa coisa deleted the codex/190-copy-resource-mode branch April 24, 2026 01:43
@github-project-automation github-project-automation Bot moved this from Backlog to Released in PHP Fast Forward Project Apr 24, 2026
github-actions Bot added a commit that referenced this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

dev-tools:sync fails when copying git hooks into consumer .git/hooks

1 participant