Skip to content

Commit

Permalink
Improve sync output (#2332)
Browse files Browse the repository at this point in the history
Improve output of synced commits, to make clear the source and
destination.
  • Loading branch information
unmultimedio authored Aug 1, 2023
1 parent f824579 commit cd1ea4c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,30 +219,36 @@ func sync(
if err != nil {
return fmt.Errorf("new syncer: %w", err)
}
return syncer.Sync(ctx, func(ctx context.Context, commit bufsync.ModuleCommit) error {
return syncer.Sync(ctx, func(ctx context.Context, moduleCommit bufsync.ModuleCommit) error {
syncPoint, err := pushOrCreate(
ctx,
clientConfig,
repo,
commit.Commit(),
commit.Branch(),
commit.Tags(),
commit.Identity(),
commit.Bucket(),
moduleCommit.Commit(),
moduleCommit.Branch(),
moduleCommit.Tags(),
moduleCommit.Identity(),
moduleCommit.Bucket(),
createWithVisibility,
)
if err != nil {
// We failed to push. We fail hard on this because the error may be recoverable
// (i.e., the BSR may be down) and we should re-attempt this commit.
return fmt.Errorf(
"failed to push %s at %s: %w",
commit.Identity().IdentityString(),
commit.Commit().Hash(),
"failed to push or create %s at %s: %w",
moduleCommit.Identity().IdentityString(),
moduleCommit.Commit().Hash(),
err,
)
}
_, err = container.Stderr().Write([]byte(
fmt.Sprintf("%s:%s\n", commit.Identity().IdentityString(), syncPoint.BsrCommitName)),
// from local -> to remote
// <git-branch>:<git-commit-hash> -> <module-identity>:<bsr-commit-name>
fmt.Sprintf(
"%s:%s -> %s:%s\n",
moduleCommit.Branch(), moduleCommit.Commit().Hash().Hex(),
moduleCommit.Identity().IdentityString(), syncPoint.BsrCommitName,
)),
)
return err
})
Expand Down

0 comments on commit cd1ea4c

Please sign in to comment.