From 7410dd87afa8a01f27c9a099c9abfdc6582190c7 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Thu, 4 Jun 2026 19:36:05 -0400 Subject: [PATCH] Include log tail in release failure notifications --- bin/repo | 2 ++ helpers/basecamp-notifier.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/bin/repo b/bin/repo index bce345f..be33824 100755 --- a/bin/repo +++ b/bin/repo @@ -40,6 +40,8 @@ if [[ -n "$LOG_MIRROR" ]]; then else LOG_FILE="$LOG_DIR/repo_${TIMESTAMP}.log" fi +export LOG_FILE +export OMARCHY_LOG_FILE="$LOG_FILE" # Show usage show_usage() { diff --git a/helpers/basecamp-notifier.sh b/helpers/basecamp-notifier.sh index c48cda3..24f7746 100644 --- a/helpers/basecamp-notifier.sh +++ b/helpers/basecamp-notifier.sh @@ -19,15 +19,44 @@ notify_basecamp() { "$BASECAMP_CHATBOT_URL" 2>/dev/null || true } +basecamp_html_escape() { + sed -e 's/&/\&/g' -e 's//\>/g' +} + +basecamp_strip_ansi() { + sed -E $'s/\x1B\\[[0-9;?]*[ -/]*[@-~]//g' +} + +basecamp_format_log_tail_html() { + local log_file="$1" + local lines="${2:-25}" + + [[ -n "$log_file" && -f "$log_file" ]] || return 0 + + tail -n "$lines" "$log_file" 2>/dev/null | + tr -d '\r' | + basecamp_strip_ansi | + basecamp_html_escape | + sed ':a;N;$!ba;s/\n/
/g' +} + notify_error() { local title="$1" local details="${2:-}" + local log_file="${OMARCHY_LOG_FILE:-${LOG_FILE:-}}" + local log_tail_lines="${BASECAMP_LOG_TAIL_LINES:-25}" + local log_tail="" local content="🔴 ${title}" if [[ -n "$details" ]]; then content+="
${details}" fi + log_tail=$(basecamp_format_log_tail_html "$log_file" "$log_tail_lines") + if [[ -n "$log_tail" ]]; then + content+="

Last ${log_tail_lines} log lines:
${log_tail}" + fi + notify_basecamp "$content" }