Skip to content

Commit

Permalink
Delete branch message as a push result (#7233)
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 authored Jan 2, 2024
1 parent 4097431 commit 0b7283c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
10 changes: 7 additions & 3 deletions go/libraries/doltcore/env/actions/remotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 6 additions & 13 deletions integration-tests/bats/sql-server-remotesrv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit 0b7283c

Please sign in to comment.