diff --git a/go/libraries/doltcore/doltdb/hooksdatabase.go b/go/libraries/doltcore/doltdb/hooksdatabase.go index 05137728651..9f0ab06353d 100644 --- a/go/libraries/doltcore/doltdb/hooksdatabase.go +++ b/go/libraries/doltcore/doltdb/hooksdatabase.go @@ -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. @@ -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 +} diff --git a/integration-tests/bats/replication.bats b/integration-tests/bats/replication.bats index f69487ea607..4ac1623f2dd 100644 --- a/integration-tests/bats/replication.bats +++ b/integration-tests/bats/replication.bats @@ -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 @@ -568,6 +560,7 @@ SQL } @test "replication: pull all heads pulls tags" { + dolt clone file://./rem1 repo2 cd repo2 dolt checkout -b new_feature @@ -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