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

Closed
github-bot wants to merge 1 commit from gh-pr/253/head into gh-pr/253/base
Owner

@⁠SkippySteve on GitHub · 2026-11-24 01:50 UTC · original
SkippySteve/victory-pr-own-next6 → main · +27 −0 · 2 files · 1 commits · closed without merging

.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.
**@⁠SkippySteve** on GitHub · 2026-11-24 01:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/253) `SkippySteve/victory-pr-own-next6` → `main` · +27 −0 · 2 files · 1 commits · closed without merging `.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.
Git outside Windows skips a hook without the executable bit and only
prints a hint, so after `cargo xtask install-hooks` commits on Linux and
macOS never ran `cargo xtask policy --staged`. Mark .githooks/pre-commit
100755 and add an xtask test that fails if a tracked hook loses the bit.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:46 +00:00
github-bot closed this pull request 2026-11-26 03:56:46 +00:00
Author
Owner

@⁠SkippySteve on GitHub · 2026-11-24 02:28 UTC · original

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

**@⁠SkippySteve** on GitHub · 2026-11-24 02:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/253#issuecomment-7120175541) Superseded by #246, which now includes this change (rebased onto main, with its test).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!253
No description provided.