fix: extract restore_to_backlog() to eliminate duplicate label reset pattern
The cleanup_labels + curl POST + CLAIMED=false pattern was duplicated across dev-agent.sh (idle_timeout and crashed cases) and phase-handler.sh (PHASE:crashed handler), triggering duplicate-detection CI failure. Extract restore_to_backlog() shared helper; call it from all three sites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7f9cefa847
commit
7156f21e12
2 changed files with 13 additions and 22 deletions
|
|
@ -131,6 +131,16 @@ cleanup_labels() {
|
||||||
"${API}/issues/${ISSUE}/labels/${IN_PROGRESS_LABEL_ID}" >/dev/null 2>&1 || true
|
"${API}/issues/${ISSUE}/labels/${IN_PROGRESS_LABEL_ID}" >/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore_to_backlog() {
|
||||||
|
cleanup_labels
|
||||||
|
curl -sf -X POST \
|
||||||
|
-H "Authorization: token ${CODEBERG_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"${API}/issues/${ISSUE}/labels" \
|
||||||
|
-d "{\"labels\":[${BACKLOG_LABEL_ID}]}" >/dev/null 2>&1 || true
|
||||||
|
CLAIMED=false # Don't unclaim again in cleanup()
|
||||||
|
}
|
||||||
|
|
||||||
CLAIMED=false
|
CLAIMED=false
|
||||||
cleanup() {
|
cleanup() {
|
||||||
rm -f "$LOCKFILE" "$STATUSFILE"
|
rm -f "$LOCKFILE" "$STATUSFILE"
|
||||||
|
|
@ -750,13 +760,7 @@ case "${_MONITOR_LOOP_EXIT:-}" in
|
||||||
echo "{\"issue\":${ISSUE},\"pr\":${PR_NUMBER:-0},\"reason\":\"${_MONITOR_LOOP_EXIT:-idle_timeout}\",\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" \
|
echo "{\"issue\":${ISSUE},\"pr\":${PR_NUMBER:-0},\"reason\":\"${_MONITOR_LOOP_EXIT:-idle_timeout}\",\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" \
|
||||||
>> "${FACTORY_ROOT}/supervisor/escalations-${PROJECT_NAME}.jsonl"
|
>> "${FACTORY_ROOT}/supervisor/escalations-${PROJECT_NAME}.jsonl"
|
||||||
# Restore labels: remove in-progress, add backlog
|
# Restore labels: remove in-progress, add backlog
|
||||||
cleanup_labels
|
restore_to_backlog
|
||||||
curl -sf -X POST \
|
|
||||||
-H "Authorization: token ${CODEBERG_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${API}/issues/${ISSUE}/labels" \
|
|
||||||
-d "{\"labels\":[${BACKLOG_LABEL_ID}]}" >/dev/null 2>&1 || true
|
|
||||||
CLAIMED=false # Don't unclaim again in cleanup()
|
|
||||||
if [ -n "${PR_NUMBER:-}" ]; then
|
if [ -n "${PR_NUMBER:-}" ]; then
|
||||||
log "keeping worktree (PR #${PR_NUMBER} still open)"
|
log "keeping worktree (PR #${PR_NUMBER} still open)"
|
||||||
else
|
else
|
||||||
|
|
@ -771,13 +775,7 @@ case "${_MONITOR_LOOP_EXIT:-}" in
|
||||||
# Belt-and-suspenders: _on_phase_change(PHASE:crashed) handles primary
|
# Belt-and-suspenders: _on_phase_change(PHASE:crashed) handles primary
|
||||||
# cleanup, but ensure labels and files are cleaned up if callback was
|
# cleanup, but ensure labels and files are cleaned up if callback was
|
||||||
# interrupted (e.g. set -e propagation).
|
# interrupted (e.g. set -e propagation).
|
||||||
cleanup_labels
|
restore_to_backlog
|
||||||
curl -sf -X POST \
|
|
||||||
-H "Authorization: token ${CODEBERG_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${API}/issues/${ISSUE}/labels" \
|
|
||||||
-d "{\"labels\":[${BACKLOG_LABEL_ID}]}" >/dev/null 2>&1 || true
|
|
||||||
CLAIMED=false
|
|
||||||
if [ -z "${PR_NUMBER:-}" ]; then
|
if [ -z "${PR_NUMBER:-}" ]; then
|
||||||
cleanup_worktree
|
cleanup_worktree
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -726,14 +726,7 @@ $(printf '%s' "$REFUSAL_JSON" | head -c 2000)
|
||||||
>> "${FACTORY_ROOT}/supervisor/escalations-${PROJECT_NAME}.jsonl"
|
>> "${FACTORY_ROOT}/supervisor/escalations-${PROJECT_NAME}.jsonl"
|
||||||
|
|
||||||
# Restore backlog label so issue can be retried
|
# Restore backlog label so issue can be retried
|
||||||
cleanup_labels
|
restore_to_backlog
|
||||||
curl -sf -X POST \
|
|
||||||
-H "Authorization: token ${CODEBERG_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${API}/issues/${ISSUE}/labels" \
|
|
||||||
-d "{\"labels\":[${BACKLOG_LABEL_ID}]}" >/dev/null 2>&1 || true
|
|
||||||
|
|
||||||
CLAIMED=false # Don't unclaim again in cleanup()
|
|
||||||
if [ -n "${PR_NUMBER:-}" ]; then
|
if [ -n "${PR_NUMBER:-}" ]; then
|
||||||
log "keeping worktree (PR #${PR_NUMBER} still open)"
|
log "keeping worktree (PR #${PR_NUMBER} still open)"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue