Skip to content

Commit

Permalink
Merge pull request #7377 from dolthub/zachmu/replicate-tags
Browse files Browse the repository at this point in the history
Push tags on remote replication
  • Loading branch information
zachmu authored Jan 20, 2024
2 parents 9360c4e + 3ea7acb commit b981bef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
11 changes: 10 additions & 1 deletion go/libraries/doltcore/doltdb/hooksdatabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ type CommitHook interface {
HandleError(ctx context.Context, err error) error
// SetLogger lets clients specify an output stream for HandleError
SetLogger(ctx context.Context, wr io.Writer) error

// ExecuteForWorkingSets returns whether or not the hook should be executed for working set updates
ExecuteForWorkingSets() bool
}

// NotifyWaitFailedCommitHook is an optional interface that can be implemented by CommitHooks.
// If a commit hook supports this interface, it can be notified if waiting for
// replication in the callback returned by |Execute| failed to complete in time
// or returned an error.
Expand Down Expand Up @@ -186,3 +187,11 @@ func (db hooksDatabase) UpdateWorkingSet(ctx context.Context, ds datas.Dataset,
}
return ds, err
}

func (db hooksDatabase) Tag(ctx context.Context, ds datas.Dataset, commitAddr hash.Hash, opts datas.TagOptions) (datas.Dataset, error) {
ds, err := db.Database.Tag(ctx, ds, commitAddr, opts)
if err == nil {
db.ExecuteCommitHooks(ctx, ds, false)
}
return ds, err
}
35 changes: 27 additions & 8 deletions integration-tests/bats/replication.bats
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ SQL
dolt sql -q "select count(*) from dolt_log()"
}

@test "replication: tag does not trigger replication" {
cd repo1
dolt config --local --add sqlserver.global.dolt_replicate_to_remote backup1
dolt tag

[ ! -d "../bac1/.dolt" ] || false
}

@test "replication: pull on read" {
dolt clone file://./rem1 repo2
cd repo2
Expand Down Expand Up @@ -568,6 +560,7 @@ SQL
}

@test "replication: pull all heads pulls tags" {

dolt clone file://./rem1 repo2
cd repo2
dolt checkout -b new_feature
Expand All @@ -585,6 +578,32 @@ SQL
[[ "$output" =~ "v1" ]] || false
}

@test "replication: tag is pushed" {
cd repo1
dolt config --local --add sqlserver.global.dolt_replicate_to_remote remote1
dolt config --local --add sqlserver.global.dolt_replicate_all_heads 1
dolt tag tag1

cd ../
dolt clone file://./rem1 repo2
cd repo2

dolt config --local --add sqlserver.global.dolt_replicate_all_heads 1
dolt config --local --add sqlserver.global.dolt_read_replica_remote origin
run dolt tag
[ "$status" -eq 0 ]
[[ "$output" =~ "tag1" ]] || false

cd ../repo1
dolt sql -q "call dolt_tag('tag2')"

cd ../repo2
run dolt sql -q "select * from dolt_tags"
[ "$status" -eq 0 ]
[[ "$output" =~ "tag1" ]] || false
[[ "$output" =~ "tag2" ]] || false
}

@test "replication: pull creates remote tracking branches" {
dolt clone file://./rem1 repo2
cd repo2
Expand Down

0 comments on commit b981bef

Please sign in to comment.