dolt merge doesn't fail if unable to get hash

This commit is contained in:
Stephanie You
2023-07-19 12:52:45 -07:00
parent 508630b383
commit ea418cda38
2 changed files with 15 additions and 13 deletions

View File

@@ -149,19 +149,21 @@ func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string,
// calculate merge stats
if !apr.Contains(cli.AbortParam) {
mergeHash, err := getHashOf(queryist, sqlCtx, apr.Arg(0))
if err != nil {
//todo: refs with the `remotes/` prefix will fail to get a hash
mergeHash, mergeHashErr := getHashOf(queryist, sqlCtx, apr.Arg(0))
if mergeHashErr != nil {
cli.Println("merge finished, but failed to get hash of merge ref")
cli.Println(err.Error())
return 0
cli.Println(mergeHashErr.Error())
}
headHash, err := getHashOf(queryist, sqlCtx, "HEAD")
if err != nil {
headHash, headhHashErr := getHashOf(queryist, sqlCtx, "HEAD")
if headhHashErr != nil {
cli.Println("merge finished, but failed to get hash of HEAD")
cli.Println(err.Error())
return 0
cli.Println(headhHashErr.Error())
}
cli.Println("Updating", headHash+".."+mergeHash)
if mergeHashErr == nil && headhHashErr == nil {
cli.Println("Updating", headHash+".."+mergeHash)
}
if apr.Contains(cli.SquashParam) {
cli.Println("Squash commit -- not updating HEAD")
}

View File

@@ -940,12 +940,12 @@ SQL
[[ ! "$output" =~ "test commit" ]] || false
run dolt merge origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "up-to-date" ]]
[[ "$output" =~ "Already up to date." ]] || false
run dolt fetch
[ "$status" -eq 0 ]
run dolt merge origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Fast-forward" ]]
[[ "$output" =~ "Fast-forward" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test commit" ]] || false
@@ -974,12 +974,12 @@ SQL
cd "dolt-repo-clones/test-repo"
run dolt merge remotes/origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date" ]]
[[ "$output" =~ "Already up to date." ]] || false
run dolt fetch origin main
[ "$status" -eq 0 ]
run dolt merge remotes/origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Fast-forward" ]]
[[ "$output" =~ "Fast-forward" ]] || false
}
@test "remotes: try to push a remote that is behind tip" {