diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2019-11-06 11:05:00 -0800 |
---|---|---|
committer | Vadim Bendebury <vbendeb@google.com> | 2019-11-12 21:08:54 +0000 |
commit | dff919493aae85d2462b614c9cb4eedeb23fdb96 (patch) | |
tree | 2814d645998ea02f7de8ca068aa1f76768337799 | |
parent | 3164d40e2247d42537aef8e80fa7e048e14bec9f (diff) | |
download | git-repo-dff919493aae85d2462b614c9cb4eedeb23fdb96.tar.gz |
sync: report list of failing git trees
When repo sync fails because some git trees are not in clean state and
as such can not be rebased automatically, it is a pain to figure out
which trees are the culprits.
With this patch the list of offending trees is printed when repo sync
reports checkout errors.
TEST=ran 'repo sync' and observed the proper list of directories show
up after the final error message
Bug: https://crbug.com/gerrit/11293
Change-Id: Icdf1a03e9014ecb184f331f513cc9a2efc7d11ed
Signed-off-by: Vadim Bendebury <vbendeb@google.com>
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244053
Reviewed-by: Mike Frysinger <vapier@google.com>
-rw-r--r-- | subcmds/sync.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 9b4a6147..97da6204 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -440,7 +440,7 @@ later is required to fix a server side protocol bug. | |||
440 | finally: | 440 | finally: |
441 | sem.release() | 441 | sem.release() |
442 | 442 | ||
443 | def _CheckoutOne(self, opt, project, lock, pm, err_event): | 443 | def _CheckoutOne(self, opt, project, lock, pm, err_event, err_results): |
444 | """Checkout work tree for one project | 444 | """Checkout work tree for one project |
445 | 445 | ||
446 | Args: | 446 | Args: |
@@ -452,6 +452,8 @@ later is required to fix a server side protocol bug. | |||
452 | lock held). | 452 | lock held). |
453 | err_event: We'll set this event in the case of an error (after printing | 453 | err_event: We'll set this event in the case of an error (after printing |
454 | out info about the error). | 454 | out info about the error). |
455 | err_results: A list of strings, paths to git repos where checkout | ||
456 | failed. | ||
455 | 457 | ||
456 | Returns: | 458 | Returns: |
457 | Whether the fetch was successful. | 459 | Whether the fetch was successful. |
@@ -496,6 +498,8 @@ later is required to fix a server side protocol bug. | |||
496 | raise | 498 | raise |
497 | finally: | 499 | finally: |
498 | if did_lock: | 500 | if did_lock: |
501 | if not success: | ||
502 | err_results.append(project.relpath) | ||
499 | lock.release() | 503 | lock.release() |
500 | finish = time.time() | 504 | finish = time.time() |
501 | self.event_log.AddSync(project, event_log.TASK_SYNC_LOCAL, | 505 | self.event_log.AddSync(project, event_log.TASK_SYNC_LOCAL, |
@@ -528,6 +532,7 @@ later is required to fix a server side protocol bug. | |||
528 | threads = set() | 532 | threads = set() |
529 | sem = _threading.Semaphore(syncjobs) | 533 | sem = _threading.Semaphore(syncjobs) |
530 | err_event = _threading.Event() | 534 | err_event = _threading.Event() |
535 | err_results = [] | ||
531 | 536 | ||
532 | for project in all_projects: | 537 | for project in all_projects: |
533 | # Check for any errors before running any more tasks. | 538 | # Check for any errors before running any more tasks. |
@@ -542,7 +547,8 @@ later is required to fix a server side protocol bug. | |||
542 | project=project, | 547 | project=project, |
543 | lock=lock, | 548 | lock=lock, |
544 | pm=pm, | 549 | pm=pm, |
545 | err_event=err_event) | 550 | err_event=err_event, |
551 | err_results=err_results) | ||
546 | if syncjobs > 1: | 552 | if syncjobs > 1: |
547 | t = _threading.Thread(target=self._CheckoutWorker, | 553 | t = _threading.Thread(target=self._CheckoutWorker, |
548 | kwargs=kwargs) | 554 | kwargs=kwargs) |
@@ -560,6 +566,9 @@ later is required to fix a server side protocol bug. | |||
560 | # If we saw an error, exit with code 1 so that other scripts can check. | 566 | # If we saw an error, exit with code 1 so that other scripts can check. |
561 | if err_event.isSet(): | 567 | if err_event.isSet(): |
562 | print('\nerror: Exited sync due to checkout errors', file=sys.stderr) | 568 | print('\nerror: Exited sync due to checkout errors', file=sys.stderr) |
569 | if err_results: | ||
570 | print('Failing repos:\n%s' % '\n'.join(err_results), | ||
571 | file=sys.stderr) | ||
563 | sys.exit(1) | 572 | sys.exit(1) |
564 | 573 | ||
565 | def _GCProjects(self, projects): | 574 | def _GCProjects(self, projects): |