Skip to content

Commit

Permalink
Checkout a trunk instead of switching to the detached HEAD (#273)
Browse files Browse the repository at this point in the history
Addressed #246
  • Loading branch information
Konboi authored May 13, 2024
1 parent cd6a3f4 commit 8cbf917
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/actions/sync_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ func SyncStack(ctx context.Context,
" - deleting merged branch ", colors.UserInput(currentBranch),
"\n",
)
if _, err := repo.Git("switch", "--detach"); err != nil {
return errors.Errorf("cannot switch to detached HEAD: %v", err)

trunk, _ := meta.Trunk(tx, currentBranch)
if _, err := repo.CheckoutBranch(&git.CheckoutBranch{Name: trunk}); err != nil {
return errors.Errorf("cannot checkout to trunk %s: %v", trunk, err)
}
if _, err := repo.Git("branch", "-D", currentBranch); err != nil {
return errors.Errorf("cannot delete merged branch %q: %v", currentBranch, err)
Expand Down

0 comments on commit 8cbf917

Please sign in to comment.