Skip to content

Commit 3017f37

Browse files
committed
add check to avoid unnecessary remote selection prompt
1 parent 9c6286a commit 3017f37

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

cmd/modify.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,18 @@ func checkModifyPreconditions(cfg *config.Config) (*loadStackResult, error) {
300300

301301
// Ensure trunk branch exists locally (it may be absent if the user
302302
// renamed their initial branch before starting the stack).
303-
remote, err := pickRemote(cfg, result.CurrentBranch, "")
304-
if err != nil {
305-
if !errors.Is(err, errInterrupt) {
306-
cfg.Errorf("failed to resolve remote: %s", err)
303+
if !git.BranchExists(s.Trunk.Branch) {
304+
remote, err := pickRemote(cfg, result.CurrentBranch, "")
305+
if err != nil {
306+
if !errors.Is(err, errInterrupt) {
307+
cfg.Errorf("failed to resolve remote: %s", err)
308+
}
309+
return nil, ErrSilent
310+
}
311+
if err := ensureLocalTrunk(cfg, s.Trunk.Branch, remote); err != nil {
312+
cfg.Errorf("%s", err)
313+
return nil, ErrSilent
307314
}
308-
return nil, ErrSilent
309-
}
310-
if err := ensureLocalTrunk(cfg, s.Trunk.Branch, remote); err != nil {
311-
cfg.Errorf("%s", err)
312-
return nil, ErrSilent
313315
}
314316

315317
// Show loading indicator while syncing PRs

0 commit comments

Comments
 (0)