aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2023-07-06 06:51:37 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-07-06 06:51:37 +0000
commitfb4456e8112d0f62397b3447a92eb2373acdc66f (patch)
treee2213b1a5118c58556a8fc2a9dd9920fdc7af5a7
parentfd588da10475fc9d76f99c1e698dffe18197f927 (diff)
parent1739927ab88a785317e8a7bdc05a66f5fe9d9b68 (diff)
downloadrepohooks-fb4456e8112d0f62397b3447a92eb2373acdc66f.tar.gz
pre-upload: show all possible fixup commands while running am: 1739927ab8
Original change: https://android-review.googlesource.com/c/platform/tools/repohooks/+/2621054 Change-Id: I67c487401791efb38013fc29d3c2d0290d04f4d1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rwxr-xr-xpre-upload.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/pre-upload.py b/pre-upload.py
index c539dfd..bdb5b36 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -64,6 +64,7 @@ class Output(object):
PASSED = COLOR.color(COLOR.GREEN, 'PASSED')
FAILED = COLOR.color(COLOR.RED, 'FAILED')
WARNING = COLOR.color(COLOR.YELLOW, 'WARNING')
+ FIXUP = COLOR.color(COLOR.MAGENTA, 'FIXUP')
# How long a hook is allowed to run before we warn that it is "too slow".
_SLOW_HOOK_DURATION = datetime.timedelta(seconds=30)
@@ -175,6 +176,21 @@ class Output(object):
print(error, file=sys.stderr)
self.success = False
+ def hook_fixups(
+ self,
+ project_results: rh.results.ProjectResults,
+ hook_results: List[rh.results.HookResult],
+ ) -> None:
+ """Display summary of possible fixups for a single hook."""
+ for result in (x for x in hook_results if x.fixup_cmd):
+ cmd = result.fixup_cmd + list(result.files)
+ for line in (
+ f'[{self.FIXUP}] {result.hook} has automated fixups available',
+ f' cd {rh.shell.quote(project_results.workdir)} && \\',
+ f' {rh.shell.cmd_to_str(cmd)}',
+ ):
+ rh.terminal.print_status_line(line, print_newline=True)
+
def finish(self):
"""Print summary for all the hooks."""
header = self.PASSED if self.success else self.FAILED
@@ -391,6 +407,7 @@ def _run_project_hooks_in_cwd(
output.hook_warning(hook, warning)
if error is not None:
output.hook_error(hook, error)
+ output.hook_fixups(ret, hook_results)
output.hook_finish(hook, duration)
_attempt_fixes(ret, commit_list)