From 80932a3136b8ff9973f0244c603cf0829ce6215e Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sat, 25 Jan 2025 23:46:29 -0600 Subject: [PATCH] Only show every 5% in the Git progress --- cpp/ci_logic.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cpp/ci_logic.cpp b/cpp/ci_logic.cpp index b202992..2d16b13 100644 --- a/cpp/ci_logic.cpp +++ b/cpp/ci_logic.cpp @@ -400,14 +400,15 @@ static int progress_cb(const git_indexer_progress *stats, void *payload) { // Calculate percentage int pct = static_cast((static_cast(stats->received_objects) / stats->total_objects) * 100); - // 0 <= pct <= 100 - if (pct > 100) pct = 100; - if (pct < 0) pct = 0; - std::string progress_str = (pct < 10 ? "0" : "") + std::to_string(pct) + "%"; - - // Cast payload back to shared_ptr and append the percentage - auto log = static_cast*>(payload); - (*log)->append(progress_str); + if (pct % 5 == 0) { + // 0 <= pct <= 100 + if (pct > 100) pct = 100; + if (pct < 1) pct = 1; + std::string progress_str = (pct < 10 ? "0" : "") + std::to_string(pct) + "%"; + + auto log = static_cast*>(payload); + (*log)->append(progress_str); + } return 0; }