diff options
| author | Mike Frysinger <vapier@google.com> | 2020-02-19 01:45:48 -0500 |
|---|---|---|
| committer | David Pursehouse <dpursehouse@collab.net> | 2020-02-19 08:01:40 +0000 |
| commit | e50b6a7c4f0a0cf3a97c8a1eec835156f68539f8 (patch) | |
| tree | cc17ed606d928bea9f7f9f0f23339a15d063b787 | |
| parent | 8a98efee5ceffcdbe952101e5b4126531cb0bd7e (diff) | |
| download | git-repo-e50b6a7c4f0a0cf3a97c8a1eec835156f68539f8.tar.gz | |
project: handle verbose with initial clone bundle
If we're not in --verbose mode with repo sync, then omit the
per-project clone bundle progress bar.
Bug: https://crbug.com/gerrit/11293
Change-Id: Ibdf3be86d35fcbccbf6788c192189f38c577e6e9
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255854
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
| -rw-r--r-- | project.py | 26 |
1 files changed, 17 insertions, 9 deletions
| @@ -1487,9 +1487,9 @@ class Project(object): | |||
| 1487 | else: | 1487 | else: |
| 1488 | alt_dir = None | 1488 | alt_dir = None |
| 1489 | 1489 | ||
| 1490 | if clone_bundle \ | 1490 | if (clone_bundle |
| 1491 | and alt_dir is None \ | 1491 | and alt_dir is None |
| 1492 | and self._ApplyCloneBundle(initial=is_new, quiet=quiet): | 1492 | and self._ApplyCloneBundle(initial=is_new, quiet=quiet, verbose=verbose)): |
| 1493 | is_new = False | 1493 | is_new = False |
| 1494 | 1494 | ||
| 1495 | if not current_branch_only: | 1495 | if not current_branch_only: |
| @@ -2415,7 +2415,7 @@ class Project(object): | |||
| 2415 | 2415 | ||
| 2416 | return ok | 2416 | return ok |
| 2417 | 2417 | ||
| 2418 | def _ApplyCloneBundle(self, initial=False, quiet=False): | 2418 | def _ApplyCloneBundle(self, initial=False, quiet=False, verbose=False): |
| 2419 | if initial and \ | 2419 | if initial and \ |
| 2420 | (self.manifest.manifestProject.config.GetString('repo.depth') or | 2420 | (self.manifest.manifestProject.config.GetString('repo.depth') or |
| 2421 | self.clone_depth): | 2421 | self.clone_depth): |
| @@ -2439,7 +2439,8 @@ class Project(object): | |||
| 2439 | return False | 2439 | return False |
| 2440 | 2440 | ||
| 2441 | if not exist_dst: | 2441 | if not exist_dst: |
| 2442 | exist_dst = self._FetchBundle(bundle_url, bundle_tmp, bundle_dst, quiet) | 2442 | exist_dst = self._FetchBundle(bundle_url, bundle_tmp, bundle_dst, quiet, |
| 2443 | verbose) | ||
| 2443 | if not exist_dst: | 2444 | if not exist_dst: |
| 2444 | return False | 2445 | return False |
| 2445 | 2446 | ||
| @@ -2460,13 +2461,13 @@ class Project(object): | |||
| 2460 | platform_utils.remove(bundle_tmp) | 2461 | platform_utils.remove(bundle_tmp) |
| 2461 | return ok | 2462 | return ok |
| 2462 | 2463 | ||
| 2463 | def _FetchBundle(self, srcUrl, tmpPath, dstPath, quiet): | 2464 | def _FetchBundle(self, srcUrl, tmpPath, dstPath, quiet, verbose): |
| 2464 | if os.path.exists(dstPath): | 2465 | if os.path.exists(dstPath): |
| 2465 | platform_utils.remove(dstPath) | 2466 | platform_utils.remove(dstPath) |
| 2466 | 2467 | ||
| 2467 | cmd = ['curl', '--fail', '--output', tmpPath, '--netrc', '--location'] | 2468 | cmd = ['curl', '--fail', '--output', tmpPath, '--netrc', '--location'] |
| 2468 | if quiet: | 2469 | if quiet: |
| 2469 | cmd += ['--silent'] | 2470 | cmd += ['--silent', '--show-error'] |
| 2470 | if os.path.exists(tmpPath): | 2471 | if os.path.exists(tmpPath): |
| 2471 | size = os.stat(tmpPath).st_size | 2472 | size = os.stat(tmpPath).st_size |
| 2472 | if size >= 1024: | 2473 | if size >= 1024: |
| @@ -2488,12 +2489,17 @@ class Project(object): | |||
| 2488 | 2489 | ||
| 2489 | if IsTrace(): | 2490 | if IsTrace(): |
| 2490 | Trace('%s', ' '.join(cmd)) | 2491 | Trace('%s', ' '.join(cmd)) |
| 2492 | if verbose: | ||
| 2493 | print('%s: Downloading bundle: %s' % (self.name, srcUrl)) | ||
| 2494 | stdout = None if verbose else subprocess.PIPE | ||
| 2495 | stderr = None if verbose else subprocess.STDOUT | ||
| 2491 | try: | 2496 | try: |
| 2492 | proc = subprocess.Popen(cmd) | 2497 | proc = subprocess.Popen(cmd, stdout=stdout, stderr=stderr) |
| 2493 | except OSError: | 2498 | except OSError: |
| 2494 | return False | 2499 | return False |
| 2495 | 2500 | ||
| 2496 | curlret = proc.wait() | 2501 | (output, _) = proc.communicate() |
| 2502 | curlret = proc.returncode | ||
| 2497 | 2503 | ||
| 2498 | if curlret == 22: | 2504 | if curlret == 22: |
| 2499 | # From curl man page: | 2505 | # From curl man page: |
| @@ -2504,6 +2510,8 @@ class Project(object): | |||
| 2504 | print("Server does not provide clone.bundle; ignoring.", | 2510 | print("Server does not provide clone.bundle; ignoring.", |
| 2505 | file=sys.stderr) | 2511 | file=sys.stderr) |
| 2506 | return False | 2512 | return False |
| 2513 | elif curlret and not verbose and output: | ||
| 2514 | print('%s' % output, file=sys.stderr) | ||
| 2507 | 2515 | ||
| 2508 | if os.path.exists(tmpPath): | 2516 | if os.path.exists(tmpPath): |
| 2509 | if curlret == 0 and self._IsValidBundle(tmpPath, quiet): | 2517 | if curlret == 0 and self._IsValidBundle(tmpPath, quiet): |
