update merge to return 1 when there are conflicts

This commit is contained in:
Stephanie You
2023-10-04 18:27:29 -07:00
parent 039f0221dc
commit 60bcded65f
4 changed files with 26 additions and 10 deletions
+3
View File
@@ -695,14 +695,17 @@ func handleMergeErr(sqlCtx *sql.Context, queryist cli.Queryist, mergeErr error,
cli.Printf("Automatic merge failed; %d table(s) are unmerged.\n"+
"Fix conflicts and constraint violations and then commit the result.\n"+
"Use 'dolt conflicts' to investigate and resolve conflicts.\n", unmergedCnt)
return 1
} else if hasConflicts {
cli.Printf("Automatic merge failed; %d table(s) are unmerged.\n"+
"Use 'dolt conflicts' to investigate and resolve conflicts.\n", unmergedCnt)
return 1
} else if hasConstraintViolations {
cli.Printf("Automatic merge failed; %d table(s) are unmerged.\n"+
"Fix constraint violations and then commit the result.\n"+
"Constraint violations for the working set may be viewed using the 'dolt_constraint_violations' system table.\n"+
"They may be queried and removed per-table using the 'dolt_constraint_violations_TABLENAME' system table.\n", unmergedCnt)
return 1
}
if mergeErr != nil {
+5 -1
View File
@@ -137,7 +137,11 @@ func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, d
if remoteHashErr != nil {
cli.Println("pull finished, but failed to get hash of remote ref")
}
printMergeStats(rows, apr, queryist, sqlCtx, usage, remoteHash, remoteHashErr)
success := printMergeStats(rows, apr, queryist, sqlCtx, usage, remoteHash, remoteHashErr)
if success == 1 {
errChan <- errors.New(" ") //return a non-nil error for the correct exit code but no further messages to print
return
}
}()
spinner := TextSpinner{}
+17 -8
View File
@@ -144,7 +144,9 @@ SQL
# dirty the working set with changes to test2
dolt sql -q "INSERT INTO test2 VALUES (9,9,9);"
dolt merge other --no-commit
run dolt merge other --no-commit
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
dolt merge --abort
run dolt sql -q "SELECT * from dolt_merge_status"
@@ -257,7 +259,8 @@ SQL
dolt commit -m "add pk 0 = 2,2 to test1"
run dolt merge merge_branch -m "merge_branch"
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
[[ "$output" =~ "test1" ]] || false
dolt add test1
@@ -286,7 +289,8 @@ SQL
dolt commit -m "add pk 0 = 2,2 to test1"
run dolt merge merge_branch --no-commit
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
[[ "$output" =~ "test1" ]] || false
run dolt commit -m 'create a merge commit'
@@ -533,7 +537,8 @@ SQL
dolt commit -am "added row"
run dolt merge other
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
run dolt sql -q "select * from dolt_constraint_violations" -r=csv
[[ "$output" =~ "test,2" ]] || false
@@ -773,10 +778,13 @@ SQL
dolt commit -am "non-fk insert"
dolt checkout main
dolt merge right
run dolt merge right
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
dolt commit -afm "commit constraint violations"
dolt merge other --no-commit
run dolt merge other --no-commit
[[ "$output" =~ "Automatic merge failed" ]] || false
run dolt sql -r csv -q "SELECT violation_type, pk, parent_fk from dolt_constraint_violations_child;";
[[ "${lines[1]}" = "foreign key,1,1" ]] || false
@@ -827,7 +835,8 @@ SQL
dolt commit -afm "committing merge conflicts"
# merge should be allowed and previous conflicts and violations should be retained
dolt merge other2 --no-commit
run dolt merge other2 --no-commit
[[ "$output" =~ "Automatic merge failed" ]] || false
run dolt sql -r csv -q "SELECT * FROM parent;"
[[ "${lines[1]}" = "1,2" ]] || false
[[ "${lines[2]}" = "3,1" ]] || false
@@ -869,7 +878,7 @@ SQL
# Create a conflicted state by merging other into main
run dolt merge other
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -r csv -q "SELECT * FROM parent;"
+1 -1
View File
@@ -298,7 +298,7 @@ teardown() {
# Commit changes and test that a merge conflict fails the pull
dolt commit -am "adding new t1 table"
run dolt pull origin main
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "Auto-merging t1" ]] || false
[[ "$output" =~ "CONFLICT (content): Merge conflict in t1" ]] || false
[[ "$output" =~ "Automatic merge failed; 1 table(s) are unmerged." ]] || false