Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push should ignore tracking branch #7450

Merged
merged 4 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/libraries/doltcore/env/actions/remotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type ProgStopper func(cancel context.CancelFunc, wg *sync.WaitGroup, statsCh cha
func Push(ctx context.Context, tempTableDir string, mode ref.UpdateMode, destRef ref.BranchRef, remoteRef ref.RemoteRef, srcDB, destDB *doltdb.DoltDB, commit *doltdb.Commit, statsCh chan pull.Stats) error {
var err error
if mode == ref.FastForwardOnly {
canFF, err := srcDB.CanFastForward(ctx, remoteRef, commit)
canFF, err := destDB.CanFastForward(ctx, destRef, commit)

if err != nil {
return err
Expand Down
8 changes: 2 additions & 6 deletions integration-tests/bats/remotes-push-pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ SQL
@test "remotes-push-pull: try to push a remote that is behind tip" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote main
cd "dolt-repo-clones"
cd dolt-repo-clones
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql <<SQL
Expand All @@ -343,11 +343,7 @@ SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote main
cd "dolt-repo-clones/test-repo"
run dolt push origin main
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date" ]] || false
dolt fetch
cd dolt-repo-clones/test-repo
run dolt push origin main
[ "$status" -eq 1 ]
[[ "$output" =~ " ! [rejected] main -> main" ]] || false
Expand Down
42 changes: 36 additions & 6 deletions integration-tests/bats/remotes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ teardown() {

cd repo2
dolt remote add test-remote file://../remote
dolt push test-remote main
dolt checkout -b other
dolt push test-remote other
dolt branch -a
dolt checkout main
dolt branch -d other
dolt fetch test-remote

run dolt branch -a
[[ "$output" =~ "remotes/origin/other" ]] || false
[[ "$output" =~ "remotes/test-remote/other" ]] || false

run dolt branch
[[ ! "$output" =~ "other" ]] || false

Expand Down Expand Up @@ -1989,3 +1989,33 @@ SQL
[ "$status" -ne 0 ]
[[ "$output" =~ "--prune option cannot be provided with a ref spec" ]] || false
}

@test "remotes: push ignores local tracking branch" {
# https://github.com/dolthub/dolt/issues/7448
mkdir remote
mkdir cloneA

cd cloneA
dolt init
dolt remote add origin file://../remote
dolt push origin main:main
dolt checkout -b alt
dolt commit -m new --allow-empty
dolt push origin alt:alt

cd ..
dolt clone file://remote cloneB
cd cloneB
dolt merge origin/alt
dolt push origin main:main
dolt push origin :alt

cd ../cloneA
dolt checkout main
dolt checkout -B alt
dolt commit -m another --allow-empty

run dolt push origin alt:alt
[ "$status" -eq 0 ]
[[ "$output" =~ "new branch" ]] || false
}
Loading