Delete branch message as a push result (#7233)

This commit is contained in:
Neil Macneale IV
2024-01-02 15:27:25 -08:00
committed by GitHub
parent 40974315e2
commit 0b7283c87e
2 changed files with 13 additions and 16 deletions

View File

@@ -101,12 +101,16 @@ func DoPush(ctx context.Context, pushMeta *env.PushOptions, progStarter ProgStar
for _, targets := range pushMeta.Targets {
err = push(ctx, pushMeta.Rsr, pushMeta.TmpDir, pushMeta.SrcDb, pushMeta.DestDb, pushMeta.Remote, targets, progStarter, progStopper)
if err == nil {
if targets.HasUpstream {
// TODO: should add commit hash info for branches with upstream set
// (e.g. 74476cf38..080b073e7 branch1 -> branch1)
// TODO: we don't have sufficient information here to know what actually happened in the push. Supporting
// git behavior of printing the commit ids updated (e.g. 74476cf38..080b073e7 branch1 -> branch1) isn't
// currently possible. We need to plumb through results in the return from the Push(). Having just an error
// response is not sufficient, as there are many "success" cases that are not errors.
if targets.SrcRef == ref.EmptyBranchRef {
successPush = append(successPush, fmt.Sprintf(" - [deleted] %s", targets.DestRef.GetPath()))
} else {
successPush = append(successPush, fmt.Sprintf(" * [new branch] %s -> %s", targets.SrcRef.GetPath(), targets.DestRef.GetPath()))
}
} else if errors.Is(err, doltdb.ErrIsAhead) || errors.Is(err, ErrCantFF) || errors.Is(err, datas.ErrMergeNeeded) {
failedPush = append(failedPush, fmt.Sprintf(" ! [rejected] %s -> %s (non-fast-forward)", targets.SrcRef.GetPath(), targets.DestRef.GetPath()))
continue

View File

@@ -557,11 +557,7 @@ GRANT CLONE_ADMIN ON *.* TO clone_admin_user@'localhost';
run dolt push origin --user $SQL_USER :new_branch
[[ "$status" -eq 0 ]] || false
# TODO - verify output. Currently we always print "new branch"
# To https://doltremoteapi.dolthub.com/dolthub/macneale-remote-test
# * [new branch] HEAD -> main
# [[ "$output" =~ "[deleted] new_branch" ]] || false
[[ "$output" =~ "- [deleted] new_branch" ]] || false
cd ../remote
run dolt branch -a
@@ -593,12 +589,9 @@ GRANT CLONE_ADMIN ON *.* TO clone_admin_user@'localhost';
[[ "$status" -ne 0 ]] || false
[[ "$output" =~ "target has uncommitted changes. --force required to overwrite" ]] || false
dolt push origin --force --user $SQL_USER :new_branch
# TODO - verify output. Currently we always print "new branch"
# To https://doltremoteapi.dolthub.com/dolthub/macneale-remote-test
# * [new branch] HEAD -> main
# [[ "$output" =~ "[deleted] new_branch" ]] || false
run dolt push origin --force --user $SQL_USER :new_branch
[[ "$status" -eq 0 ]] || false
[[ "$output" =~ "- [deleted] new_branch" ]] || false
cd ../remote
run dolt branch -a
@@ -628,11 +621,11 @@ GRANT CLONE_ADMIN ON *.* TO clone_admin_user@'localhost';
run dolt push nodb --user $SQL_USER main:new_branch
[[ "$status" -ne 0 ]] || false
[[ "$output" =~ "database not found: nodb" ]] || false # NM4
[[ "$output" =~ "database not found: nodb" ]] || false
run dolt push --force nodb --user $SQL_USER main:new_branch
[[ "$status" -ne 0 ]] || false
[[ "$output" =~ "database not found: nodb" ]] || false # NM4
[[ "$output" =~ "database not found: nodb" ]] || false
}
@test "sql-server-remotesrv: create remote branch from remotesapi port as super user" {