Reduce duplicate Jeannie progress repaints

This commit is contained in:
juvdiaz 2026-07-01 14:27:42 -06:00
parent 0cda6573ad
commit d80960fce0
1 changed files with 22 additions and 7 deletions

29
jeannie
View File

@ -823,13 +823,8 @@ jeannie_step_progress() {
local description="$1"
local step_log="$2"
local started_at="$3"
local last_line="${4:-}"
local elapsed=$((SECONDS - started_at))
local last_line=""
if [[ -s "${step_log}" ]]; then
last_line="$(tail -n 1 "${step_log}" 2>/dev/null || true)"
last_line="$(jeannie_compact_text "${last_line}" 88)"
fi
printf '\r'
jeannie_step_prefix "${description}"
@ -841,6 +836,17 @@ jeannie_step_progress() {
printf '\033[K'
}
jeannie_step_latest_progress_line() {
local step_log="$1"
local last_line=""
if [[ -s "${step_log}" ]]; then
last_line="$(tail -n 1 "${step_log}" 2>/dev/null || true)"
last_line="$(jeannie_compact_text "${last_line}" 88)"
fi
printf '%s' "${last_line}"
}
redact_sensitive_output() {
sed -E \
-e 's/(GITEA_BOOTSTRAP_PASSWORD=)["'\'']?[^"'\''[:space:]]+["'\'']?/\1[REDACTED]/g' \
@ -862,6 +868,9 @@ run_step() {
local progress_pid
local progress_interval="${JEANNIE_PROGRESS_INTERVAL_SECONDS:-10}"
local started_at
local current_progress_line=""
local last_progress_line=""
local last_progress_rendered_at=0
shift
JEANNIE_STEP_INDEX=$((JEANNIE_STEP_INDEX + 1))
@ -894,7 +903,13 @@ run_step() {
while kill -0 "${progress_pid}" >/dev/null 2>&1; do
sleep "${progress_interval}"
if kill -0 "${progress_pid}" >/dev/null 2>&1; then
jeannie_step_progress "${description}" "${step_log}" "${started_at}"
current_progress_line="$(jeannie_step_latest_progress_line "${step_log}")"
if [[ "${current_progress_line}" != "${last_progress_line}" ]] ||
((SECONDS - last_progress_rendered_at >= 60)); then
jeannie_step_progress "${description}" "${step_log}" "${started_at}" "${current_progress_line}"
last_progress_line="${current_progress_line}"
last_progress_rendered_at="${SECONDS}"
fi
fi
done
wait "${progress_pid}" || true