fix: support configurable default remote#171
Conversation
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Assisted-by: opencode:gpt-5.5
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a selectable remote for resolving default base refs: introduces a Changes
Sequence DiagramsequenceDiagram
actor User
participant CLI as git gtr new
participant Core as lib/core.sh
participant Git as Git
User->>CLI: git gtr new --remote upstream
alt remote provided
CLI->>Core: remote = "upstream"
else remote omitted
CLI->>Core: resolve_default_remote()
Core-->>CLI: remote (from config/env/default)
end
CLI->>Core: resolve_default_branch(remote)
Core->>Git: read refs/remotes/remote/HEAD
Git-->>Core: default branch name
Core->>Git: git fetch remote
Core->>Git: git branch --track <branch> remote/<default_branch>
Core->>Git: git worktree add -b <branch> remote/<default_branch>
Git-->>Core: worktree created
Core-->>CLI: success
CLI-->>User: Worktree created from remote/<default_branch>
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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`:
- Around line 141-143: The parameter-expansion line using default_branch and
$remote can misinterpret special characters in the remote name; update the
pattern to treat the remote name as a literal by using the braced variable form
inside the expansion (i.e., change the use of
"${default_branch#refs/remotes/$remote/}" to use
"${default_branch#refs/remotes/${remote}/}") so the variable is expanded
literally; locate the assignment to default_branch and the parameter-expansion
that strips "refs/remotes/…" and replace the unbraced $remote with ${remote}.
🪄 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: Enterprise
Run ID: 6d4967db-15c2-45da-acf8-ad025dc38dd8
📒 Files selected for processing (12)
README.mdcompletions/_git-gtrcompletions/git-gtr.fishcompletions/gtr.bashdocs/configuration.mdlib/commands/create.shlib/commands/help.shlib/config.shlib/core.shscripts/generate-completions.shtests/cmd_create_integration.batstests/core_create_worktree.bats
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Assisted-by: opencode:gpt-5.5
Pull Request
Description
gtr.defaultRemote/GTR_DEFAULT_REMOTEandgit gtr new --remote.Motivation
Fixes #170.
Type of Change
Testing
distrobox enter fedora -- bash -lc 'bats tests/'distrobox enter fedora -- bash -lc 'shellcheck lib/core.sh lib/commands/create.sh lib/config.sh scripts/generate-completions.sh'./scripts/generate-completions.sh --checkgit diff --checkPATH="$PWD/bin:$PATH" git gtr help new./bin/gtr help newManual Testing Checklist
Tested on:
Core functionality tested:
git gtr new <branch>- Create worktreegit gtr config- Configuration commandsgit gtr new --remoteTest Steps
cmd_create --remoteusing a selected remote default branch.create_worktreetracking a branch from the selected remote.Expected behavior:
--remote upstreamandgtr.defaultRemote=upstreamuseupstream/<default-branch>.Actual behavior:
Matches expected.
Breaking Changes
Checklist
git gtr(production) and./bin/gtr(development)License Acknowledgment
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.
PR opened by gpt-5.5 on opencode
Summary by CodeRabbit
New Features
--remoteflag togit gtr newto choose which remote supplies default base refs.gtr.defaultRemoteconfiguration option (defaults toorigin).Documentation
--remoteflag andgtr.defaultRemote.Chores
Tests