fix: resolve gtr/coreutils naming conflict and add cd completions#125
fix: resolve gtr/coreutils naming conflict and add cd completions#125
Conversation
Closes #124 - Reverse binary relationship: bin/git-gtr is now the main entry point, bin/gtr becomes a convenience wrapper. This allows the Homebrew formula to stop installing bin/gtr, eliminating the conflict with coreutils. - Add --as flag to git gtr init so users can choose a custom function name (e.g. eval "$(git gtr init zsh --as gwtr)") to avoid shadowing coreutils gtr in their shell. - Add cd completions to init output for all three shells (bash, zsh, fish). Worktree names are completed via git gtr list --porcelain. - Add 26 BATS tests for the init command covering --as flag, name validation, cd completions, and shell output correctness.
WalkthroughReclassifies binaries so Changes
Sequence Diagram(s)sequenceDiagram
participant UserShell as "User Shell"
participant GTR as "bin/gtr"
participant GitGTR as "bin/git-gtr"
participant ShellInit as "Shell (init output)"
UserShell->>GTR: run `gtr ...` or `git gtr ...`
GTR->>GitGTR: exec ./git-gtr "$@"
GitGTR->>GitGTR: source libs, load commands
alt command == init
GitGTR->>ShellInit: emit shell-specific function (with --as if provided)
ShellInit-->>UserShell: function code printed for eval
else other command
GitGTR->>GitGTR: dispatch to cmd_* handler
GitGTR-->>UserShell: command result / exit
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scripts/generate-completions.sh (1)
611-629:⚠️ Potential issue | 🟡 MinorAdd a case for
gtr.ui.colorto provide a meaningful description.The
gtr.ui.colorkey falls through to the default case (line 627), which just echoes the key name as the description. This results in unhelpful completion output in Fish.📝 Suggested fix
gtr.hook.postCd) desc="Post-cd hook (shell integration only)" ;; + gtr.ui.color) desc="Color output mode (auto, always, never)" ;; *) desc="$key" ;;
🤖 Fix all issues with AI agents
In `@bin/git-gtr`:
- Around line 17-24: In resolve_script_dir(), the test [[ $src != /* ]] leaves
$src unquoted which can break on spaces or glob chars; change that check to use
the quoted variable (i.e., [[ "$src" != /* ]]) so the symlink resolution handles
paths with spaces or special chars correctly and remains consistent with the
"always quote variables" guideline.
In `@completions/git-gtr.fish`:
- Line 143: Replace the non-descriptive description string 'gtr.ui.color' with a
user-friendly explanation for the gtr.ui.color setting (refer to the
gtr.ui.color key in the diff), e.g. "Color used for UI elements" or "UI theme
color (hex or name)"; update the single-quoted description to clearly state what
the setting controls and any expected format so users understand its purpose and
valid values.
- Quote $src in resolve_script_dir symlink check (bin/git-gtr) - Add gtr.ui.color description in fish config completions - Add gtr.ui.color case in generate-completions.sh
Summary
Closes #124
Reverse binary relationship:
bin/git-gtris now the main entry point (sources libs, containsmain()dispatcher).bin/gtrbecomes a thin convenience wrapper. This allows the Homebrew formula to dropbin.install "bin/gtr", eliminating the conflict with coreutilsgtr(GNU tr).Add
--asflag togit gtr init: Users with coreutils can pick a non-conflicting shell function name:Add
cdcompletions to init output: All three shells (bash, zsh, fish) now completecdas a subcommand with worktree names viagit gtr list --porcelain.26 new BATS tests for the init command (262 total, all passing).
Homebrew formula follow-up
The Homebrew formula in
coderabbitai/homebrew-tapneeds a separate update to removebin.install "bin/gtr"— the binary reversal in this PR makes that safe to do.Test plan
bats tests/init.bats— 26 new tests passbats tests/— all 262 tests pass./scripts/generate-completions.sh --check— completions in syncshellcheck bin/gtr bin/git-gtr— cleaneval "$(git gtr init zsh --as gwtr)"thengwtr cd <tab>completes worktrees🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests