diff options
author | Kuang-che Wu <kcwu@google.com> | 2024-10-24 10:12:39 +0800 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-10-24 16:21:28 +0000 |
commit | 70a4e643e66af182709f0888d7727f54fb6b7ea9 (patch) | |
tree | b53fc16d6fddbf4776065b7c380c404b628ffb77 | |
parent | 8da4861b3860c505e39341b4135c21f67569e4d8 (diff) | |
download | git-repo-70a4e643e66af182709f0888d7727f54fb6b7ea9.tar.gz |
progress: always show done message
The done message was omitted if the task is shorter than 0.5s. This
might confuse users.
Bug: b/371638995
Change-Id: I3fdd2cd8daea16d34fba88457d09397fff71af15
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/440222
Tested-by: Kuang-che Wu <kcwu@google.com>
Commit-Queue: Kuang-che Wu <kcwu@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
-rw-r--r-- | progress.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/progress.py b/progress.py index 290265c6..fe246c74 100644 --- a/progress.py +++ b/progress.py | |||
@@ -100,6 +100,7 @@ class Progress: | |||
100 | self._show = not delay | 100 | self._show = not delay |
101 | self._units = units | 101 | self._units = units |
102 | self._elide = elide and _TTY | 102 | self._elide = elide and _TTY |
103 | self._quiet = quiet | ||
103 | 104 | ||
104 | # Only show the active jobs section if we run more than one in parallel. | 105 | # Only show the active jobs section if we run more than one in parallel. |
105 | self._show_jobs = False | 106 | self._show_jobs = False |
@@ -114,13 +115,7 @@ class Progress: | |||
114 | ) | 115 | ) |
115 | self._update_thread.daemon = True | 116 | self._update_thread.daemon = True |
116 | 117 | ||
117 | # When quiet, never show any output. It's a bit hacky, but reusing the | 118 | if not quiet and show_elapsed: |
118 | # existing logic that delays initial output keeps the rest of the class | ||
119 | # clean. Basically we set the start time to years in the future. | ||
120 | if quiet: | ||
121 | self._show = False | ||
122 | self._start += 2**32 | ||
123 | elif show_elapsed: | ||
124 | self._update_thread.start() | 119 | self._update_thread.start() |
125 | 120 | ||
126 | def _update_loop(self): | 121 | def _update_loop(self): |
@@ -160,7 +155,7 @@ class Progress: | |||
160 | msg = self._last_msg | 155 | msg = self._last_msg |
161 | self._last_msg = msg | 156 | self._last_msg = msg |
162 | 157 | ||
163 | if not _TTY or IsTraceToStderr(): | 158 | if not _TTY or IsTraceToStderr() or self._quiet: |
164 | return | 159 | return |
165 | 160 | ||
166 | elapsed_sec = time.time() - self._start | 161 | elapsed_sec = time.time() - self._start |
@@ -202,7 +197,7 @@ class Progress: | |||
202 | 197 | ||
203 | def end(self): | 198 | def end(self): |
204 | self._update_event.set() | 199 | self._update_event.set() |
205 | if not _TTY or IsTraceToStderr() or not self._show: | 200 | if not _TTY or IsTraceToStderr() or self._quiet: |
206 | return | 201 | return |
207 | 202 | ||
208 | duration = duration_str(time.time() - self._start) | 203 | duration = duration_str(time.time() - self._start) |