From 0b7283c87e465db579ec62901acaf79ccb3f6fad Mon Sep 17 00:00:00 2001 From: Neil Macneale IV <46170177+macneale4@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:27:25 -0800 Subject: [PATCH] Delete branch message as a push result (#7233) --- go/libraries/doltcore/env/actions/remotes.go | 10 +++++++--- .../bats/sql-server-remotesrv.bats | 19 ++++++------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/go/libraries/doltcore/env/actions/remotes.go b/go/libraries/doltcore/env/actions/remotes.go index 3fa96ad2e2..8b6a8bf9f6 100644 --- a/go/libraries/doltcore/env/actions/remotes.go +++ b/go/libraries/doltcore/env/actions/remotes.go @@ -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 diff --git a/integration-tests/bats/sql-server-remotesrv.bats b/integration-tests/bats/sql-server-remotesrv.bats index dfdf66295b..08e127dfa1 100644 --- a/integration-tests/bats/sql-server-remotesrv.bats +++ b/integration-tests/bats/sql-server-remotesrv.bats @@ -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" {