fix repo root resolution from subdirectories#166
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughIntroduces a centralized Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/core.sh`:
- Line 19: The assignment to root using _resolve_main_repo_root can cause an
early exit under set -e if the command fails; guard the call by checking its
exit status (e.g., use if ! root=$(_resolve_main_repo_root); then ... fi or
root=$(_resolve_main_repo_root) || true) so failures are handled gracefully
instead of triggering set -e; update the block around the root variable
assignment and ensure subsequent logic that depends on root handles the
empty/failure case appropriately.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 178ea85b-96e7-4e4d-8d75-4c85c29035e1
📒 Files selected for processing (5)
lib/config.shlib/core.shtests/cmd_list.batstests/config.batstests/core_resolve_target.bats
Summary
git rev-parse --git-common-direven when Git returns a relative path from a main-repo subdirectorydiscover_repo_root()and.gtrconfiglookup so subdirectory execution is consistentcmd_list,discover_repo_root, and_gtrconfig_pathfrom a main-repo subdirectoryRoot Cause
git rev-parse --git-common-dirreturns relative paths like../.gitwhengtrruns from a subdirectory of the main repository. The existing code only handled.gitand absolute worktree paths, so it collapsed the repo root to..and mis-resolved.gtrconfig.Validation
shellcheck lib/config.sh lib/core.shbats tests/config.bats tests/core_resolve_target.bats tests/cmd_list.batsbats tests/(cd lib && /Users/tommy/Documents/GitHub/git-worktree-runner/bin/gtr list)Closes #161.
Summary by CodeRabbit
Refactor
Tests