From cd1ea4c0e64e0bb7cbc2618055505405cdfc8d1b Mon Sep 17 00:00:00 2001 From: Julian Figueroa Date: Tue, 1 Aug 2023 15:53:54 -0500 Subject: [PATCH] Improve sync output (#2332) Improve output of synced commits, to make clear the source and destination. --- .../command/alpha/repo/reposync/reposync.go | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go b/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go index ffa5d47057..423166b7bd 100644 --- a/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go +++ b/private/buf/cmd/buf/command/alpha/repo/reposync/reposync.go @@ -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 + // : -> : + fmt.Sprintf( + "%s:%s -> %s:%s\n", + moduleCommit.Branch(), moduleCommit.Commit().Hash().Hex(), + moduleCommit.Identity().IdentityString(), syncPoint.BsrCommitName, + )), ) return err })