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 <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger
2021-02-23 18:38:39 -05:00
parent fbb95a4342
commit 7b586f231b
2 changed files with 22 additions and 6 deletions

View File

@ -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'