fix: repository detection from subdirectories#129
Open
BlackPool25 wants to merge 2 commits into
Open
Conversation
Replace os.Stat('.git') with git rev-parse --is-inside-work-tree so
lrc hooks install/uninstall --local works from any subdirectory.
Rename IsGitRepositoryCurrentDir to IsGitRepository to match function
purpose. Add E2E subdirectory tests.
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.
Summary
Fixes brittle repository detection when running
lrc hooks install --localandlrc hooks uninstall --localfrom nested subdirectories of a Git repository.IsGitRepositoryCurrentDir→IsGitRepositoryingitops/config.go. Replacedos.Stat(".git")(only works at repo root) withgit rev-parse --is-inside-work-tree(traverses parent dirs correctly).isGitRepository()ininternal/appcore/hooks_management.goto call the renamed function.tests/worktree-hooks.sh.Root Cause
IsGitRepositoryCurrentDir()usedos.Stat(".git")which resolves relative to the current working directory. When invoked from a subdirectory, the.gitentry is not found even though CWD is inside a valid Git worktree.Changes Made
gitops/config.go— Replace function body, rename, remove unused"os"importinternal/appcore/hooks_management.go— Update delegate calltests/worktree-hooks.sh— Add "Local Hook Management In Subdirectories" test sectionTesting
make test-go— All Go packages passmake test-hooks-worktree— All 32 tests pass (including 10 new subdirectory tests)Checklist
storage/responsibilities, I updatedstorage/storage_status.mdand ranmake check-status-doc. (No storage changes)network/responsibilities, I updatednetwork/network_status.mdand ranmake check-status-doc. (No network changes)SECURITY.mdand updated related documentation if needed. (No security-sensitive changes)Linked Issue
Fixes #128
Notes For Reviewers
The new E2E tests in
tests/worktree-hooks.shunder "Local Hook Management In Subdirectories" verify install, status, and uninstall from a nested subdirectory.