diff options
author | Mike Frysinger <vapier@google.com> | 2023-06-09 21:56:29 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2023-06-09 21:57:08 -0400 |
commit | 5c139d804bbe48ad3e7ac2184c313b9ac7be9ce7 (patch) | |
tree | 4f7cb6b58e073d48d2a6d83554476d67573dc39e | |
parent | 9cf5981041ce307d9a8a7f59032f093fcc9328d9 (diff) | |
download | repohooks-5c139d804bbe48ad3e7ac2184c313b9ac7be9ce7.tar.gz |
pre-upload: add progress counter for commits too
When uploading multiple commits, it can be nice to see how many
there are left to go.
Bug: None
Test: unittests
Change-Id: I2e9c84eabd5c364a4ac87a6d862678263d62b3da
-rwxr-xr-x | pre-upload.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/pre-upload.py b/pre-upload.py index ee0639e..cf97e10 100755 --- a/pre-upload.py +++ b/pre-upload.py @@ -75,6 +75,8 @@ class Output(object): self.project_name = project_name self.num_hooks = None self.hook_index = 0 + self.num_commits = None + self.commit_index = 0 self.success = True self.start_time = datetime.datetime.now() self.hook_start_time = None @@ -88,6 +90,15 @@ class Output(object): """ self.num_hooks = num_hooks + def set_num_commits(self, num_commits: int) -> None: + """Keep track of how many commits we'll be running. + + Args: + num_commits: Number of commits to be run. + """ + self.num_commits = num_commits + self.commit_index = 1 + def commit_start(self, commit, commit_summary): """Emit status for new commit. @@ -95,9 +106,14 @@ class Output(object): commit: commit hash. commit_summary: commit summary. """ - status_line = f'[{self.COMMIT} {commit[0:12]}] {commit_summary}' + status_line = ( + f'[{self.COMMIT} ' + f'{self.commit_index}/{self.num_commits} ' + f'{commit[0:12]}] {commit_summary}' + ) rh.terminal.print_status_line(status_line, print_newline=True) self.hook_index = 1 + self.commit_index += 1 def hook_start(self, hook_name): """Emit status before the start of a hook. @@ -315,6 +331,7 @@ def _run_project_hooks_in_cwd(project_name, proj_dir, output, from_git=False, co if not commit_list: commit_list = rh.git.get_commits( ignore_merged_commits=config.ignore_merged_commits) + output.set_num_commits(len(commit_list)) ret = True fixup_list = [] |