diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-22 00:07:35 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-03-14 04:02:42 +0000 |
commit | 4847e0574303f90438335a7c6c7c009145deb8ef (patch) | |
tree | 97190c4cad95c1b4ece90394ec5023d3a63ac7c1 /project.py | |
parent | bb8ee7f54a4e0bf07d466304d800f13ec41ac21c (diff) | |
download | git-repo-4847e0574303f90438335a7c6c7c009145deb8ef.tar.gz |
repo/init/sync: rework default git download output
When we download git sources, we get a progress bar (good) and we get
a dump of all the refs we downloaded (bad) as it can easily be 100+ if
not 1000+ depending on the project (for each git repo!). Lets rework
the output behavior so that:
* quiet: Only errors.
* default: Progress bars (if on a tty).
* verbose: Full output (progress bars & downloaded refs).
Bug: https://crbug.com/gerrit/11293
Change-Id: I87a380075e79de6805f91095876dd1b37d32873a
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256456
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -2440,8 +2440,10 @@ class Project(object): | |||
2440 | if os.path.exists(os.path.join(self.gitdir, 'shallow')): | 2440 | if os.path.exists(os.path.join(self.gitdir, 'shallow')): |
2441 | cmd.append('--depth=2147483647') | 2441 | cmd.append('--depth=2147483647') |
2442 | 2442 | ||
2443 | if quiet: | 2443 | if not verbose: |
2444 | cmd.append('--quiet') | 2444 | cmd.append('--quiet') |
2445 | if not quiet and sys.stdout.isatty(): | ||
2446 | cmd.append('--progress') | ||
2445 | if not self.worktree: | 2447 | if not self.worktree: |
2446 | cmd.append('--update-head-ok') | 2448 | cmd.append('--update-head-ok') |
2447 | cmd.append(name) | 2449 | cmd.append(name) |
@@ -2498,7 +2500,7 @@ class Project(object): | |||
2498 | ok = False | 2500 | ok = False |
2499 | for _i in range(2): | 2501 | for _i in range(2): |
2500 | gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy, | 2502 | gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy, |
2501 | merge_output=True, capture_stdout=not verbose) | 2503 | merge_output=True, capture_stdout=quiet) |
2502 | ret = gitcmd.Wait() | 2504 | ret = gitcmd.Wait() |
2503 | if ret == 0: | 2505 | if ret == 0: |
2504 | ok = True | 2506 | ok = True |
@@ -2578,8 +2580,10 @@ class Project(object): | |||
2578 | return False | 2580 | return False |
2579 | 2581 | ||
2580 | cmd = ['fetch'] | 2582 | cmd = ['fetch'] |
2581 | if quiet: | 2583 | if not verbose: |
2582 | cmd.append('--quiet') | 2584 | cmd.append('--quiet') |
2585 | if not quiet and sys.stdout.isatty(): | ||
2586 | cmd.append('--progress') | ||
2583 | if not self.worktree: | 2587 | if not self.worktree: |
2584 | cmd.append('--update-head-ok') | 2588 | cmd.append('--update-head-ok') |
2585 | cmd.append(bundle_dst) | 2589 | cmd.append(bundle_dst) |
@@ -2639,9 +2643,8 @@ class Project(object): | |||
2639 | # 22: HTTP page not retrieved. The requested url was not found or | 2643 | # 22: HTTP page not retrieved. The requested url was not found or |
2640 | # returned another error with the HTTP error code being 400 or above. | 2644 | # returned another error with the HTTP error code being 400 or above. |
2641 | # This return code only appears if -f, --fail is used. | 2645 | # This return code only appears if -f, --fail is used. |
2642 | if not quiet: | 2646 | if verbose: |
2643 | print("Server does not provide clone.bundle; ignoring.", | 2647 | print('Server does not provide clone.bundle; ignoring.') |
2644 | file=sys.stderr) | ||
2645 | return False | 2648 | return False |
2646 | elif curlret and not verbose and output: | 2649 | elif curlret and not verbose and output: |
2647 | print('%s' % output, file=sys.stderr) | 2650 | print('%s' % output, file=sys.stderr) |