From 05022740ac882b9afc868d8b2a17a9c2cf57d552 Mon Sep 17 00:00:00 2001 From: Agent Date: Sun, 5 Apr 2026 18:50:09 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20fix:=20dev-poll=20abandons=20fresh=20PRs?= =?UTF-8?q?=20=E2=80=94=20stale=20branch=20check=20fails=20on=20unfetched?= =?UTF-8?q?=20refs=20(#248)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/dev-poll.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dev/dev-poll.sh b/dev/dev-poll.sh index dd58306..fbd165f 100755 --- a/dev/dev-poll.sh +++ b/dev/dev-poll.sh @@ -371,6 +371,9 @@ if [ -f "$LOCKFILE" ]; then rm -f "$LOCKFILE" fi +# --- Fetch origin refs before any stale branch checks --- +git fetch origin --prune 2>/dev/null || true + # --- Memory guard --- memory_guard 2000 @@ -430,7 +433,7 @@ if [ "$ORPHAN_COUNT" -gt 0 ]; then if [ -n "$HAS_PR" ]; then # Check if branch is stale (behind primary branch) BRANCH="fix/issue-${ISSUE_NUM}" - AHEAD=$(git rev-list --count "origin/${BRANCH}..origin/${PRIMARY_BRANCH}" 2>/dev/null || echo "999") + AHEAD=$(git rev-list --count "origin/${BRANCH}..origin/${PRIMARY_BRANCH}" 2>/dev/null || echo "0") if [ "$AHEAD" -gt 0 ]; then log "issue #${ISSUE_NUM} PR #${HAS_PR} is $AHEAD commits behind ${PRIMARY_BRANCH} — abandoning stale PR" # Close the PR via API @@ -682,7 +685,7 @@ for i in $(seq 0 $((BACKLOG_COUNT - 1))); do if [ -n "$EXISTING_PR" ]; then # Check if branch is stale (behind primary branch) BRANCH="fix/issue-${ISSUE_NUM}" - AHEAD=$(git rev-list --count "origin/${BRANCH}..origin/${PRIMARY_BRANCH}" 2>/dev/null || echo "999") + AHEAD=$(git rev-list --count "origin/${BRANCH}..origin/${PRIMARY_BRANCH}" 2>/dev/null || echo "0") if [ "$AHEAD" -gt 0 ]; then log "issue #${ISSUE_NUM} PR #${EXISTING_PR} is $AHEAD commits behind ${PRIMARY_BRANCH} — abandoning stale PR" # Close the PR via API