Skip to content

Conversation

@damianlewis
Copy link
Contributor

@damianlewis damianlewis commented Dec 17, 2025

Pull Request

Description

Fix the remove command to display the folder name instead of the current branch name in the log message, making it consistent with the create command.

Motivation

The remove command was displaying the current branch name ($branch_name) instead of the folder name being removed. This was confusing when:

  • Branch names contain slashes (feature/auth → folder feature-auth)
  • A different branch was checked out in the worktree
  • Custom --name suffix was used during creation

Since git gtr rm removes a folder (worktree), the log message should show what is actually being removed.

Fixes #52

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Other (please describe):

Testing

Manual Testing Checklist

Tested on:

  • macOS
  • Linux (specify distro: _______)
  • Windows (Git Bash)

Core functionality tested:

  • git gtr new <branch> - Create worktree
  • git gtr go <branch> - Navigate to worktree
  • git gtr editor <branch> - Open in editor (if applicable)
  • git gtr ai <branch> - Start AI tool (if applicable)
  • git gtr rm <branch> - Remove worktree
  • git gtr list - List worktrees
  • git gtr config - Configuration commands (if applicable)
  • Other commands affected by this change: N/A

Test Steps

  1. Create worktree with slashes: git gtr new feature/test
  2. Remove worktree: git gtr rm feature/test
  3. Verify output shows folder name: ==> Removing worktree: feature-test

Expected behavior: Log message shows folder name being removed.

Actual behavior: Log message now correctly shows folder name.

Additional tests:

  • Created worktree, checked out different branch, removed by folder name - shows folder name (verified)
  • Created worktree with --name suffix - shows full folder name (verified)

Breaking Changes

  • This PR introduces breaking changes
  • I have discussed this in an issue first
  • Migration guide is included in documentation

Checklist

Before submitting this PR, please check:

  • I have read CONTRIBUTING.md
  • My code follows the project's style guidelines
  • I have performed manual testing on at least one platform
  • I have updated documentation (README.md, CLAUDE.md, etc.) if needed
  • My changes work on multiple platforms (or I've noted platform-specific behavior)
  • I have added/updated shell completions (if adding new commands or flags)
  • I have tested with both git gtr (production) and ./bin/gtr (development)
  • No new external dependencies are introduced (Bash + git only)
  • All existing functionality still works

Additional Context

The fix uses $(basename "$worktree_path") which follows existing codebase conventions (e.g., line 858 uses the same inline pattern for log messages).


License Acknowledgment

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.

Summary by CodeRabbit

  • Bug Fixes
    • Improved logging clarity in the worktree removal process to display the worktree path instead of branch name for better identification.

✏️ Tip: You can customize this high-level summary in your review settings.

The remove command was showing the current branch name instead of the
folder name being removed. This was confusing when:
- Branch names contain slashes (feature/auth -> folder feature-auth)
- A different branch was checked out in the worktree
- Custom --name suffix was used

Since git gtr rm removes a folder (worktree), the log message should
show what's actually being removed, consistent with the create command.

Fixes coderabbitai#52
@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

The git gtr rm command's log message now displays the removed worktree's folder name instead of the current branch name, addressing the inconsistency where the logged identifier didn't match the actual folder being removed.

Changes

Cohort / File(s) Summary
Remove command log message fix
bin/gtr
Changed log message in remove flow to display basename of worktree path instead of branch name for consistency and accuracy

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-line variable substitution in a log message
  • No control flow or logic changes
  • Direct fix addressing the reported issue with minimal surface area for defects

Poem

A rabbit hops through the git tree,
Where folders now log accurately,
No more branch names in the fray—
The worktree's true name saves the day! 🐰
Simple fix, a log message swapped,
Now the confusion has stopped.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing branch name display with folder name display in the remove command.
Linked Issues check ✅ Passed The PR directly addresses issue #52 by changing the remove command to display the folder name using basename of the worktree path instead of the branch name.
Out of Scope Changes check ✅ Passed The changes are focused solely on fixing the log message in the remove flow as specified in issue #52, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 35d8119 and ed59e33.

📒 Files selected for processing (1)
  • bin/gtr (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
bin/gtr

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

bin/gtr: Dispatch commands through cmd_* functions in bin/gtr (case block lines 36‑77)
Update GTR_VERSION on line 8 of bin/gtr when releasing; this affects gtr version / --version output

Global set -e in bin/gtr: guard non-critical commands with || true

list --porcelain output must remain stable for scripting purposes

Update version number in bin/gtr (line 8, GTR_VERSION constant) when releasing a new version

Files:

  • bin/gtr
{bin/gtr,lib/**/*.sh,adapters/**/*.sh}

📄 CodeRabbit inference engine (.github/instructions/testing.instructions.md)

{bin/gtr,lib/**/*.sh,adapters/**/*.sh}: All commands must exit 0 (except intentional failures) and produce expected side-effects
No unquoted path errors; spaces must be handled in file paths
Hooks must run only once per creation/removal event

Files:

  • bin/gtr
🔇 Additional comments (1)
bin/gtr (1)

352-352: LGTM! This correctly fixes the inconsistent log message.

The change to display $(basename "$worktree_path") instead of the branch name ensures the remove command shows the actual folder being removed. This addresses cases where:

  • Branch names contain slashes (e.g., feature/auth becomes folder feature-auth)
  • A custom --name suffix was used during creation
  • A different branch is checked out in the worktree

The approach is consistent with the create command (line 235) which displays $folder_name, and the path is properly quoted to handle spaces.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

Remove command displays branch name instead of folder name

1 participant