diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-17 01:35:18 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-02-18 03:31:33 +0000 |
commit | 31990f009719730c8be9d33b8d6cc94048f6d54b (patch) | |
tree | 369ca676378b902dba89918a0a0bca7103892301 | |
parent | 16f2fae16f37d0ff77c7ba1ba58ccca036f6358b (diff) | |
download | git-repo-31990f009719730c8be9d33b8d6cc94048f6d54b.tar.gz |
project: move successful fetch output behind verbose
Syncing projects works fine the majority of the time. So rather than
dump all of that noisy output to stdout, lets capture it and only show
when things fail or in verbose mode. This tidies up the default `repo
sync` output.
Bug: https://crbug.com/gerrit/11293
Change-Id: I8314dd92e1e6aadeb26e36a8c92610da419684e6
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255413
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
-rw-r--r-- | git_command.py | 8 | ||||
-rw-r--r-- | project.py | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/git_command.py b/git_command.py index c7e94fd0..26668a39 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -226,6 +226,7 @@ class GitCommand(object): | |||
226 | provide_stdin=False, | 226 | provide_stdin=False, |
227 | capture_stdout=False, | 227 | capture_stdout=False, |
228 | capture_stderr=False, | 228 | capture_stderr=False, |
229 | merge_output=False, | ||
229 | disable_editor=False, | 230 | disable_editor=False, |
230 | ssh_proxy=False, | 231 | ssh_proxy=False, |
231 | cwd=None, | 232 | cwd=None, |
@@ -277,7 +278,7 @@ class GitCommand(object): | |||
277 | stdin = None | 278 | stdin = None |
278 | 279 | ||
279 | stdout = subprocess.PIPE | 280 | stdout = subprocess.PIPE |
280 | stderr = subprocess.PIPE | 281 | stderr = subprocess.STDOUT if merge_output else subprocess.PIPE |
281 | 282 | ||
282 | if IsTrace(): | 283 | if IsTrace(): |
283 | global LAST_CWD | 284 | global LAST_CWD |
@@ -305,6 +306,8 @@ class GitCommand(object): | |||
305 | dbg += ' 1>|' | 306 | dbg += ' 1>|' |
306 | if stderr == subprocess.PIPE: | 307 | if stderr == subprocess.PIPE: |
307 | dbg += ' 2>|' | 308 | dbg += ' 2>|' |
309 | elif stderr == subprocess.STDOUT: | ||
310 | dbg += ' 2>&1' | ||
308 | Trace('%s', dbg) | 311 | Trace('%s', dbg) |
309 | 312 | ||
310 | try: | 313 | try: |
@@ -352,7 +355,8 @@ class GitCommand(object): | |||
352 | p = self.process | 355 | p = self.process |
353 | s_in = platform_utils.FileDescriptorStreams.create() | 356 | s_in = platform_utils.FileDescriptorStreams.create() |
354 | s_in.add(p.stdout, sys.stdout, 'stdout') | 357 | s_in.add(p.stdout, sys.stdout, 'stdout') |
355 | s_in.add(p.stderr, sys.stderr, 'stderr') | 358 | if p.stderr is not None: |
359 | s_in.add(p.stderr, sys.stderr, 'stderr') | ||
356 | self.stdout = '' | 360 | self.stdout = '' |
357 | self.stderr = '' | 361 | self.stderr = '' |
358 | 362 | ||
@@ -2365,7 +2365,8 @@ class Project(object): | |||
2365 | 2365 | ||
2366 | ok = False | 2366 | ok = False |
2367 | for _i in range(2): | 2367 | for _i in range(2): |
2368 | gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy) | 2368 | gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy, |
2369 | merge_output=True, capture_stdout=not verbose) | ||
2369 | ret = gitcmd.Wait() | 2370 | ret = gitcmd.Wait() |
2370 | if ret == 0: | 2371 | if ret == 0: |
2371 | ok = True | 2372 | ok = True |
@@ -2388,6 +2389,8 @@ class Project(object): | |||
2388 | elif ret < 0: | 2389 | elif ret < 0: |
2389 | # Git died with a signal, exit immediately | 2390 | # Git died with a signal, exit immediately |
2390 | break | 2391 | break |
2392 | if not verbose: | ||
2393 | print('%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr) | ||
2391 | time.sleep(random.randint(30, 45)) | 2394 | time.sleep(random.randint(30, 45)) |
2392 | 2395 | ||
2393 | if initial: | 2396 | if initial: |