diff options
| author | Mike Frysinger <vapier@google.com> | 2021-02-23 18:38:39 -0500 |
|---|---|---|
| committer | Mike Frysinger <vapier@google.com> | 2021-02-25 20:13:18 +0000 |
| commit | 7b586f231ba116d16b89639e04d940ae008ffff2 (patch) | |
| tree | 0a2c1a07224d1489711c48c86f243c3571718ad8 /subcmds/sync.py | |
| parent | fbb95a43421eb925985223fffa3febc12e5dbe33 (diff) | |
| download | git-repo-7b586f231ba116d16b89639e04d940ae008ffff2.tar.gz | |
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>
Diffstat (limited to 'subcmds/sync.py')
| -rw-r--r-- | subcmds/sync.py | 7 |
1 files changed, 7 insertions, 0 deletions
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 @@ | |||
| 13 | # limitations under the License. | 13 | # limitations under the License. |
| 14 | 14 | ||
| 15 | import http.cookiejar as cookielib | 15 | import http.cookiejar as cookielib |
| 16 | import io | ||
| 16 | import json | 17 | import json |
| 17 | import netrc | 18 | import netrc |
| 18 | from optparse import SUPPRESS_HELP | 19 | from optparse import SUPPRESS_HELP |
| @@ -354,6 +355,7 @@ later is required to fix a server side protocol bug. | |||
| 354 | # - We always make sure we unlock the lock if we locked it. | 355 | # - We always make sure we unlock the lock if we locked it. |
| 355 | start = time.time() | 356 | start = time.time() |
| 356 | success = False | 357 | success = False |
| 358 | buf = io.StringIO() | ||
| 357 | with lock: | 359 | with lock: |
| 358 | pm.start(project.name) | 360 | pm.start(project.name) |
| 359 | try: | 361 | try: |
| @@ -361,6 +363,7 @@ later is required to fix a server side protocol bug. | |||
| 361 | success = project.Sync_NetworkHalf( | 363 | success = project.Sync_NetworkHalf( |
| 362 | quiet=opt.quiet, | 364 | quiet=opt.quiet, |
| 363 | verbose=opt.verbose, | 365 | verbose=opt.verbose, |
| 366 | output_redir=buf, | ||
| 364 | current_branch_only=opt.current_branch_only, | 367 | current_branch_only=opt.current_branch_only, |
| 365 | force_sync=opt.force_sync, | 368 | force_sync=opt.force_sync, |
| 366 | clone_bundle=opt.clone_bundle, | 369 | clone_bundle=opt.clone_bundle, |
| @@ -376,6 +379,10 @@ later is required to fix a server side protocol bug. | |||
| 376 | lock.acquire() | 379 | lock.acquire() |
| 377 | did_lock = True | 380 | did_lock = True |
| 378 | 381 | ||
| 382 | output = buf.getvalue() | ||
| 383 | if opt.verbose and output: | ||
| 384 | pm.update(inc=0, msg=output.rstrip()) | ||
| 385 | |||
| 379 | if not success: | 386 | if not success: |
| 380 | err_event.set() | 387 | err_event.set() |
| 381 | print('error: Cannot fetch %s from %s' | 388 | print('error: Cannot fetch %s from %s' |
