Hooks: track pre-commit as executable so the policy check runs on Linux #253

Closed
SkippySteve wants to merge 1 commit from upstream-pr/253 into main
SkippySteve commented 2026-11-24 01:50:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T01:50:53Z.


.githooks/pre-commit is tracked as 100644. Git outside Windows skips a hook that is not executable and only prints a hint, so after cargo xtask install-hooks a commit on Linux or macOS never runs cargo xtask policy --staged:

$ git config core.hooksPath .githooks && git commit -m t
hint: The '.githooks/pre-commit' hook was ignored because it's not set as executable.

Git for Windows runs hooks regardless of the bit, so nothing changes there.

  • Mark .githooks/pre-commit as 100755 (mode change only, contents unchanged).
  • Add hooks_are_tracked_executable to xtask: it reads git ls-files --stage -- .githooks and fails if a tracked hook is not 100755 (it skips itself outside a git checkout).

Testing on Linux:

  • cargo test -p xtask: passes; with the bit flipped back via git update-index --chmod=-x the new test fails, naming the hook.
  • cargo clippy -p xtask --all-targets -- -D warnings and cargo fmt --check: clean.
  • A scratch clone with core.hooksPath=.githooks now runs the policy check on commit instead of printing the hint.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6572776922 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/253). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T01:50:53Z. --- `.githooks/pre-commit` is tracked as `100644`. Git outside Windows skips a hook that is not executable and only prints a hint, so after `cargo xtask install-hooks` a commit on Linux or macOS never runs `cargo xtask policy --staged`: ``` $ git config core.hooksPath .githooks && git commit -m t hint: The '.githooks/pre-commit' hook was ignored because it's not set as executable. ``` Git for Windows runs hooks regardless of the bit, so nothing changes there. - Mark `.githooks/pre-commit` as `100755` (mode change only, contents unchanged). - Add `hooks_are_tracked_executable` to xtask: it reads `git ls-files --stage -- .githooks` and fails if a tracked hook is not `100755` (it skips itself outside a git checkout). Testing on Linux: - `cargo test -p xtask`: passes; with the bit flipped back via `git update-index --chmod=-x` the new test fails, naming the hook. - `cargo clippy -p xtask --all-targets -- -D warnings` and `cargo fmt --check`: clean. - A scratch clone with `core.hooksPath=.githooks` now runs the policy check on commit instead of printing the hint.
upstream-sync closed this pull request 2026-11-24 06:52:04 +00:00
SkippySteve commented 2026-11-24 06:55:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T02:28:13Z.


Superseded by #246, which now includes this change (rebased onto main, with its test).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120175541 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/253#issuecomment-7120175541). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T02:28:13Z. --- Superseded by #246, which now includes this change (rebased onto main, with its test).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!253
No description provided.