Repository navigation
Conversation
Use the common hooks directory in linked worktrees and resolve relative core.hooksPath from the worktree root when called from a subdirectory.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 SummarySummary by CodeRabbit
Walkthrough
ChangesGit hook path resolution
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: 🔵 Low · up to Hook installation, removal, and status can target the wrong directory when invoked from a subdirectory on Git 2.12 with a relative hooks path. This is a narrow compatibility issue that should be fixed or explicitly accepted before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: ASSERTIVE
- Plan: Essentials
- Run ID:
90580e1d-5951-418a-90b9-8f1416dcfa5c
📒 Files selected for processing (2)
internal/githooks/install.gointernal/githooks/install_test.go
Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. Your free on-demand review promotion remains active until October 9, 2026 at 6:00 PM UTC.
📜 Review details
⏰ Context from checks skipped due to timeout. (9)
- GitHub Check: test (macos-latest, 1.27)
- GitHub Check: trivy-fs
- GitHub Check: build-onnx
- GitHub Check: build-linux-static
- GitHub Check: benchmark
- GitHub Check: test (ubuntu-latest, 1.27)
- GitHub Check: lint
- GitHub Check: govulncheck
- GitHub Check: test (windows-latest, 1.27)
|
Continued upstream as zzet#867 |
Summary
gortex githook installcould write the hook to a directory that Git never runs hooks from, so the hook was installed but never ran.uninstallandstatuslooked in the same wrong place.git rev-parse --git-dirnames the worktree's own directory (.git/worktrees/<name>). Git runs hooks from the sharedhooks/directory instead.core.hooksPath, the path was joined to the current directory. Run from a subdirectory, the hook went to<subdir>/<hooksPath>, while Git resolves the setting from the top of the worktree.Changes
HookPathForasks Git for the hooks directory withgit rev-parse --path-format=absolute --git-path hooks. Git then appliescore.hooksPath, the shared directory of linked worktrees and relative paths itself. This follows the pattern ininternal/gitstate/gitstate.go.--path-format. The fallback usesgit rev-parse --git-path hooksand makes a relative result absolute. That fallback was not tested on an old Git.core.hooksPathused from a subdirectory. Both new tests fail onmain.Testing
go test -race ./...)go test -race ./internal/githooks/passes.go vetandgolangci-lintreport no issues for the changed package.Checklist