diff --git a/dev/dev-poll.sh b/dev/dev-poll.sh index dd58306..bd3e67d 100755 --- a/dev/dev-poll.sh +++ b/dev/dev-poll.sh @@ -125,7 +125,7 @@ open_pr_exists() { # Relabel a stale in-progress issue to blocked with diagnostic comment # Args: issue_number reason -# Uses shared helpers from lib/issue-lifecycle.sh +# Returns: 0 on success, 1 on failure relabel_stale_issue() { local issue="$1" reason="$2" @@ -149,17 +149,25 @@ relabel_stale_issue() { -d "{\"labels\":[${bk_id}]}" >/dev/null 2>&1 || true fi - # Post diagnostic comment using shared helper - local comment_body - comment_body=$( + # Post diagnostic comment + local tmpfile + tmpfile=$(mktemp /tmp/stale-issue-XXXXXX.md) + { printf '### Stale in-progress issue detected\n\n' printf '| Field | Value |\n|---|---|\n' printf '| Detection reason | `%s` |\n' "$reason" printf '| Timestamp | `%s` |\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" printf '\n**Status:** This issue was labeled `in-progress` but no active tmux session exists.\n' printf '**Action required:** A maintainer should triage this issue.\n' - ) - _ilc_post_comment "$issue" "$comment_body" + } > "$tmpfile" + + jq -Rs '{body:.}' < "$tmpfile" > "${tmpfile}.json" + curl -sf -o /dev/null -X POST \ + -H "Authorization: token ${FORGE_TOKEN}" \ + -H "Content-Type: application/json" \ + "${API}/issues/${issue}/comments" \ + --data-binary @"${tmpfile}.json" 2>/dev/null || true + rm -f "$tmpfile" "${tmpfile}.json" _ilc_log "stale issue #${issue} relabeled to blocked: ${reason}" } diff --git a/lib/issue-lifecycle.sh b/lib/issue-lifecycle.sh index 6b14090..81586f9 100644 --- a/lib/issue-lifecycle.sh +++ b/lib/issue-lifecycle.sh @@ -161,27 +161,6 @@ issue_release() { _ilc_log "released issue #${issue}" } -# --------------------------------------------------------------------------- -# _ilc_post_comment — Post a comment to an issue (internal helper) -# Args: issue_number body_text -# Uses a temp file to avoid large inline strings. -# --------------------------------------------------------------------------- -_ilc_post_comment() { - local issue="$1" body="$2" - - local tmpfile tmpjson - tmpfile=$(mktemp /tmp/ilc-comment-XXXXXX.md) - tmpjson="${tmpfile}.json" - printf '%s' "$body" > "$tmpfile" - jq -Rs '{body:.}' < "$tmpfile" > "$tmpjson" - curl -sf -o /dev/null -X POST \ - -H "Authorization: token ${FORGE_TOKEN}" \ - -H "Content-Type: application/json" \ - "${FORGE_API}/issues/${issue}/comments" \ - --data-binary @"$tmpjson" 2>/dev/null || true - rm -f "$tmpfile" "$tmpjson" -} - # --------------------------------------------------------------------------- # issue_block — add "blocked" label, post diagnostic comment, remove in-progress. # Args: issue_number reason [result_text] @@ -208,9 +187,14 @@ issue_block() { fi } > "$tmpfile" - # Post comment using shared helper - _ilc_post_comment "$issue" "$(cat "$tmpfile")" - rm -f "$tmpfile" + # Post comment + jq -Rs '{body:.}' < "$tmpfile" > "${tmpfile}.json" + curl -sf -o /dev/null -X POST \ + -H "Authorization: token ${FORGE_TOKEN}" \ + -H "Content-Type: application/json" \ + "${FORGE_API}/issues/${issue}/comments" \ + --data-binary @"${tmpfile}.json" 2>/dev/null || true + rm -f "$tmpfile" "${tmpfile}.json" # Remove in-progress, add blocked local ip_id bk_id