diff options
author | Mike Frysinger <vapier@google.com> | 2023-06-08 23:47:39 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2023-06-23 23:16:33 -0400 |
commit | 1739927ab88a785317e8a7bdc05a66f5fe9d9b68 (patch) | |
tree | e2213b1a5118c58556a8fc2a9dd9920fdc7af5a7 | |
parent | c400921fda11c5c802b7d4890474e9ec5a7e579b (diff) | |
download | repohooks-1739927ab88a785317e8a7bdc05a66f5fe9d9b68.tar.gz |
pre-upload: show all possible fixup commands while runningandroidx-wear-platform-release
This allows people to quickly run fixup commands themselves if they
want. This is helpful as we only offer to run the command if there
is one fixup in the latest commit.
Show these as a summary at the end so hopefully it's a little easier
for users to access if they want to copy & paste the command.
Bug: 274529930
Test: unittests
Change-Id: I75b9c196a5369874fac94e822ec87e72f804cb9a
-rwxr-xr-x | pre-upload.py | 17 |
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) |