From 7b586f231ba116d16b89639e04d940ae008ffff2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 23 Feb 2021 18:38:39 -0500 Subject: sync: capture all git output by default The default sync output should show a progress bar only for successful commands, and the error output for any commands that fail. Implement that policy here. Bug: https://crbug.com/gerrit/11293 Change-Id: I85716032201b6e2b45df876b07dd79cb2c1447a5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297905 Reviewed-by: Michael Mortensen Tested-by: Mike Frysinger --- subcmds/sync.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'subcmds/sync.py') diff --git a/subcmds/sync.py b/subcmds/sync.py index b1b6a6ef..d1b631ae 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -13,6 +13,7 @@ # limitations under the License. import http.cookiejar as cookielib +import io import json import netrc from optparse import SUPPRESS_HELP @@ -354,6 +355,7 @@ later is required to fix a server side protocol bug. # - We always make sure we unlock the lock if we locked it. start = time.time() success = False + buf = io.StringIO() with lock: pm.start(project.name) try: @@ -361,6 +363,7 @@ later is required to fix a server side protocol bug. success = project.Sync_NetworkHalf( quiet=opt.quiet, verbose=opt.verbose, + output_redir=buf, current_branch_only=opt.current_branch_only, force_sync=opt.force_sync, clone_bundle=opt.clone_bundle, @@ -376,6 +379,10 @@ later is required to fix a server side protocol bug. lock.acquire() did_lock = True + output = buf.getvalue() + if opt.verbose and output: + pm.update(inc=0, msg=output.rstrip()) + if not success: err_event.set() print('error: Cannot fetch %s from %s' -- cgit v1.2.3-54-g00ecf