From b244dfe7ac4e75bd7e6fa5cbec89066e0a2b2a87 Mon Sep 17 00:00:00 2001 From: Elian Date: Mon, 23 Jun 2025 14:42:33 -0700 Subject: [PATCH] fix err check and multi remote branch test --- .../doltcore/sqle/dprocedures/dolt_checkout.go | 7 +++++-- integration-tests/bats/checkout.bats | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/go/libraries/doltcore/sqle/dprocedures/dolt_checkout.go b/go/libraries/doltcore/sqle/dprocedures/dolt_checkout.go index 4296a3fb9c..91a161a0e6 100644 --- a/go/libraries/doltcore/sqle/dprocedures/dolt_checkout.go +++ b/go/libraries/doltcore/sqle/dprocedures/dolt_checkout.go @@ -558,10 +558,13 @@ func checkoutExistingBranchWithWorkingSetFallback( } err = checkoutExistingBranch(ctx, dbName, branchName, apr) - } - if err != nil { + if err != nil { + return err + } + } else if err != nil { return err } + return nil } diff --git a/integration-tests/bats/checkout.bats b/integration-tests/bats/checkout.bats index 32806ebc50..ba38b68d52 100755 --- a/integration-tests/bats/checkout.bats +++ b/integration-tests/bats/checkout.bats @@ -847,7 +847,7 @@ SQL dolt checkout main - # Use explicit branch reference + # use explicit branch reference dolt checkout feature -- # verify we switched to feature branch @@ -1146,9 +1146,15 @@ SQL echo "$output" [[ "$output" =~ "'feature' matched multiple (2) remote tracking branches" ]] || false + run dolt checkout --track origin/feature + [ "$status" -eq 0 ] + echo "$output" + [[ "$output" =~ "Switched to branch 'feature'" ]] || false + [[ "$output" =~ "branch 'feature' set up to track 'origin/feature'" ]] || false + # verify we're still on main branch run dolt branch [ "$status" -eq 0 ] - [[ "$output" =~ "* main" ]] || false + [[ "$output" =~ "* feature" ]] || false }