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>
This commit is contained in:
Kuang-che Wu 2024-10-24 10:12:39 +08:00 committed by LUCI
parent 8da4861b38
commit 70a4e643e6

View File

@ -100,6 +100,7 @@ class Progress:
self._show = not delay self._show = not delay
self._units = units self._units = units
self._elide = elide and _TTY self._elide = elide and _TTY
self._quiet = quiet
# Only show the active jobs section if we run more than one in parallel. # Only show the active jobs section if we run more than one in parallel.
self._show_jobs = False self._show_jobs = False
@ -114,13 +115,7 @@ class Progress:
) )
self._update_thread.daemon = True self._update_thread.daemon = True
# When quiet, never show any output. It's a bit hacky, but reusing the if not quiet and show_elapsed:
# existing logic that delays initial output keeps the rest of the class
# clean. Basically we set the start time to years in the future.
if quiet:
self._show = False
self._start += 2**32
elif show_elapsed:
self._update_thread.start() self._update_thread.start()
def _update_loop(self): def _update_loop(self):
@ -160,7 +155,7 @@ class Progress:
msg = self._last_msg msg = self._last_msg
self._last_msg = msg self._last_msg = msg
if not _TTY or IsTraceToStderr(): if not _TTY or IsTraceToStderr() or self._quiet:
return return
elapsed_sec = time.time() - self._start elapsed_sec = time.time() - self._start
@ -202,7 +197,7 @@ class Progress:
def end(self): def end(self):
self._update_event.set() self._update_event.set()
if not _TTY or IsTraceToStderr() or not self._show: if not _TTY or IsTraceToStderr() or self._quiet:
return return
duration = duration_str(time.time() - self._start) duration = duration_str(time.time() - self._start)