Fix pre-PR gate sentinel path for git worktrees#28
Merged
Conversation
`pre-pr-gate.sh` wrote and read its sentinel at `$(git rev-parse --show-toplevel)/.git/pre-pr.ok`. In a linked git worktree `.git` is a file (a `gitdir:` pointer), not a directory, so that path can be neither written nor read — the gate always blocked `gh pr create` from a worktree, even after `/pre-pr` had passed. Resolve the real git directory with `git rev-parse --absolute-git-dir` and place the sentinel there. That is the per-worktree git dir in a worktree and plain `.git` in a regular clone, so the change is backward-compatible. Update the `pre-pr` skill and command, and the sibling `check-links` sentinel (which `pre-pr` consumes), to document the same resolved-git-dir location. Verified in a real linked worktree: the gate still blocks without a sentinel and now allows once the sentinel is written to the git dir; a plain clone is unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the pre-pr gate sentinel location so gh pr create is correctly unblocked after /pre-pr succeeds when working in linked Git worktrees (where .git is a gitdir: pointer file, not a directory). This updates both the hook implementation and the related documentation to reflect “store/read sentinels from the resolved git directory” behavior.
Changes:
- Update
scripts/pre-pr-gate.shto resolve the git directory viagit rev-parse --absolute-git-dirand readpre-pr.okfrom there. - Update
pre-prandcheck-linksskill docs to describe writing/reading sentinels from the git directory (worktree-safe). - Update the Claude
/pre-prcommand docs to match the new sentinel location guidance.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
scripts/pre-pr-gate.sh |
Reads the pre-pr.ok sentinel from the resolved git directory to support linked worktrees. |
skills/pre-pr/SKILL.md |
Updates pre-pr.ok sentinel and check-links.ok cache documentation to reference the git directory. |
skills/check-links/SKILL.md |
Updates check-links.ok sentinel documentation to be worktree-safe. |
claude/commands/pre-pr.md |
Updates the documented sentinel location to align with the worktree-safe approach. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review on PR #28: - pre-pr-gate.sh: fall back to `git rev-parse --git-dir` when `--absolute-git-dir` is unavailable (Git < 2.13), absolute-izing a relative result, so git-dir resolution can no longer fail open via `|| exit 0`. On old Git the gate now fails closed (blocks) instead. - Align the three sentinel-location docs (the `pre-pr` and `check-links` skills and the /pre-pr command) on `--absolute-git-dir`, matching the command the hook uses to read the sentinel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
armiol
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
scripts/pre-pr-gate.sh— thePreToolUsehook that blocksgh pr createuntil/pre-prhas passed — stored and read its sentinel at$(git rev-parse --show-toplevel)/.git/pre-pr.ok.In a linked git worktree,
$repo_root/.gitis a file (agitdir:pointer),not a directory, so that path can be neither written nor read. The gate therefore
always blocked
gh pr createfrom a worktree, even after/pre-prhad fullypassed. (Hit while opening SpineEventEngine/config#722
from a Claude Code worktree.)
Fix
Resolve the real git directory with
git rev-parse --absolute-git-dirand placethe sentinel there:
…/.git/worktrees/<name>/)…/.git/so the change is backward-compatible.
Docs updated to match the same resolved-git-dir location:
skills/pre-pr/SKILL.md— sentinel write (§6) and thecheck-linksshort-circuit read.claude/commands/pre-pr.md— the "Sentinel location" line.skills/check-links/SKILL.md— the siblingcheck-links.oksentinel (consumed bypre-pr), which had the identical bug.Verification
bash -nclean. Functional test in a real linked worktree (where.gitis a file):gh pr create, no sentinelgh pr create, sentinel in git dirgh pr createcommand🤖 Generated with Claude Code