Skip to content

fix: show helpful error when running git gtr cd#137

Merged
helizaga merged 1 commit intomainfrom
fix/cd-helpful-error
Feb 24, 2026
Merged

fix: show helpful error when running git gtr cd#137
helizaga merged 1 commit intomainfrom
fix/cd-helpful-error

Conversation

@helizaga
Copy link
Collaborator

@helizaga helizaga commented Feb 24, 2026

Summary

  • git gtr cd now shows a clear error explaining why it doesn't work (subprocess limitation) instead of the generic "Unknown command" message
  • Prints the exact eval "$(git gtr init <shell>)" setup command, auto-detecting the user's shell
  • Guides users to use gtr cd (the shell function wrapper) instead

Before

$ git gtr cd
[x] Unknown command: cd
Use 'git gtr help' for available commands

After

$ git gtr cd
[x] 'cd' requires shell integration (subprocesses cannot change your shell's directory)
[i] Set up with: eval "$(git gtr init zsh)"
[i] Then use:    gtr cd [<branch>]

Test plan

  • git gtr cd shows helpful error with shell-specific setup instructions
  • gtr cd (shell wrapper) still works normally
  • All 282 BATS tests pass

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced error handling for the "cd" command with improved guidance on shell integration setup and initialization instructions.

`cd` only works through the shell function wrapper (`gtr cd`) since
subprocesses cannot change the parent shell's directory. Instead of the
generic "Unknown command" error, detect `cd` and print setup instructions
with the user's shell auto-detected.
@helizaga helizaga requested a review from NatoBoram as a code owner February 24, 2026 21:04
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between daee0c1 and 405b647.

📒 Files selected for processing (1)
  • bin/git-gtr

Walkthrough

Adds a dedicated handler for the "cd" command within the main command dispatcher. When invoked, the handler determines the shell name, emits an error message indicating cd requires shell integration, and suggests initialization via git gtr init <shell> before exiting with status 1.

Changes

Cohort / File(s) Summary
CD Command Handler
bin/git-gtr
Added 8-line conditional handler for "cd" command that emits integration error message and provides initialization guidance before exiting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A hop, a stop, a gentle guide,
When cd is called with nowhere to hide,
"Init your shell!" the rabbit cries with glee,
For some commands need integration's key.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a helpful error message when running 'git gtr cd' instead of a generic unknown command message.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cd-helpful-error

Comment @coderabbitai help to get the list of available commands and usage tips.

@helizaga helizaga merged commit 050b26a into main Feb 24, 2026
4 checks passed
@helizaga helizaga deleted the fix/cd-helpful-error branch February 24, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant