Merge pull request #9155 from meirdev/fix-status-command

fix status command after removing origin from remote
This commit is contained in:
Neil Macneale IV
2025-05-02 09:13:06 -07:00
committed by GitHub
2 changed files with 28 additions and 2 deletions

View File

@@ -335,8 +335,10 @@ func getRemoteInfo(queryist cli.Queryist, sqlCtx *sql.Context, branchName string
if err != nil {
return ahead, behind, err
}
if len(remoteBranches) != 1 {
return ahead, behind, fmt.Errorf("could not find remote branch %s", remoteBranchRef)
if len(remoteBranches) > 1 {
return ahead, behind, fmt.Errorf("runtime error: too many results returned for remote branch %s", remoteBranchRef)
} else if len(remoteBranches) == 0 {
return ahead, behind, nil
}
remoteBranchCommit := remoteBranches[0][1].(string)

View File

@@ -580,3 +580,27 @@ SQL
[ "$status" -eq 0 ]
[[ "$output" =~ "modified: t1" ]] || false
}
@test "status: after remove remote" {
mkdir remote
mkdir repo1
cd repo1
dolt init
dolt remote add origin file://../remote
dolt push origin main
cd ..
dolt clone file://./remote repo2
cd repo2
run dolt remote -v
[ "$status" -eq 0 ]
[[ "$output" =~ "origin file:///" ]] || false
dolt remote rm origin
run dolt status
[ "$status" -eq 0 ]
[[ "$output" =~ "On branch main" ]] || false
}