From 70a4e643e66af182709f0888d7727f54fb6b7ea9 Mon Sep 17 00:00:00 2001 From: Kuang-che Wu Date: Thu, 24 Oct 2024 10:12:39 +0800 Subject: [PATCH] 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 Commit-Queue: Kuang-che Wu Reviewed-by: Josip Sokcevic --- progress.py | 13 ++++--------- 1 file 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: self._show = not delay self._units = units self._elide = elide and _TTY + self._quiet = quiet # Only show the active jobs section if we run more than one in parallel. self._show_jobs = False @@ -114,13 +115,7 @@ class Progress: ) self._update_thread.daemon = True - # When quiet, never show any output. It's a bit hacky, but reusing the - # 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: + if not quiet and show_elapsed: self._update_thread.start() def _update_loop(self): @@ -160,7 +155,7 @@ class Progress: msg = self._last_msg self._last_msg = msg - if not _TTY or IsTraceToStderr(): + if not _TTY or IsTraceToStderr() or self._quiet: return elapsed_sec = time.time() - self._start @@ -202,7 +197,7 @@ class Progress: def end(self): self._update_event.set() - if not _TTY or IsTraceToStderr() or not self._show: + if not _TTY or IsTraceToStderr() or self._quiet: return duration = duration_str(time.time() - self._start)