Skip to content

[bugfix/git_helper-20] Fixed Git Switch#21

Merged
justinkumpe merged 1 commit intodevfrom
bugfix/git_helper-20
Jan 6, 2026
Merged

[bugfix/git_helper-20] Fixed Git Switch#21
justinkumpe merged 1 commit intodevfrom
bugfix/git_helper-20

Conversation

@justinkumpe
Copy link
Member

@justinkumpe justinkumpe commented Jan 6, 2026

Summary by Sourcery

Fix branch switching behavior when selecting remote branches in the git helper script.

Bug Fixes:

  • Correct remote branch checkout by creating a local tracking branch when switching from a remote branch selection.

Enhancements:

  • Adjust git helper UI dimensions for improved display and update the script version number.

@justinkumpe justinkumpe self-assigned this Jan 6, 2026
@justinkumpe justinkumpe added the bug Something isn't working label Jan 6, 2026
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the git-helper script to adjust the dialog UI dimensions and correctly handle switching to remote branches by creating local tracking branches when needed.

Sequence diagram for the updated cmd_branch_switch remote branch checkout

sequenceDiagram
  actor User
  participant GitHelper as GitHelper_script
  participant Git as Git_CLI

  User->>GitHelper: invoke cmd_branch_switch
  GitHelper->>GitHelper: b = pick_branch()
  GitHelper->>GitHelper: check if b is empty
  alt branch_selected
    GitHelper->>GitHelper: test if b contains '/'
    alt remote_branch_selected
      GitHelper->>Git: git checkout --track -b branch_name b
      Git-->>GitHelper: create local tracking branch
    else local_branch_selected
      GitHelper->>Git: git checkout b
      Git-->>GitHelper: switch to local branch
    end
  else no_branch_selected
    GitHelper-->>User: return without action
  end
  GitHelper-->>User: display run_and_show output
Loading

File-Level Changes

Change Details Files
Adjusted dialog UI layout parameters to better fit typical terminal sizes.
  • Reduced overall dialog height to 12 lines to avoid overflow in smaller terminals.
  • Reduced dialog width slightly to 70 characters for better compatibility.
  • Increased menu height to 15 to show more entries within the smaller overall dialog.
git_helpers/git-helper.sh
Fixed git branch switching logic so selecting a remote branch creates a proper local tracking branch.
  • Parsed the selected branch string into remote name and branch name components when it contains a slash.
  • Changed the checkout command for remote branches to create a new local branch that tracks the remote branch using git checkout --track -b <branch_name> <remote/branch>.
  • Left the behavior for local (non-remote) branches unchanged, still using a simple git checkout.
git_helpers/git-helper.sh

Possibly linked issues

  • #bugfix/git_helper: PR changes git checkout to explicitly create local branch with full path, matching issue’s branch naming requirement.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@justinkumpe justinkumpe merged commit e1bfb1f into dev Jan 6, 2026
2 of 3 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In cmd_branch_switch, the new git checkout --track -b "$branch_name" "$b" will fail if a local branch with the same name already exists; consider checking for an existing local branch (and doing a plain checkout in that case) before creating a new one.
  • The remote_name variable in cmd_branch_switch is computed but never used; if it isn’t needed, remove it to avoid confusion and keep the function focused.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `cmd_branch_switch`, the new `git checkout --track -b "$branch_name" "$b"` will fail if a local branch with the same name already exists; consider checking for an existing local branch (and doing a plain checkout in that case) before creating a new one.
- The `remote_name` variable in `cmd_branch_switch` is computed but never used; if it isn’t needed, remove it to avoid confusion and keep the function focused.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@justinkumpe justinkumpe deleted the bugfix/git_helper-20 branch January 6, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant