diff --git a/batch-extract-50.sh b/batch-extract-50.sh index 5592a42..88ce9b8 100755 --- a/batch-extract-50.sh +++ b/batch-extract-50.sh @@ -118,8 +118,15 @@ for SOURCE in $SOURCES; do if [ "$AGE_HOURS" -ge 2 ]; then # Branch is stale — check if PR is mergeable - PR_NUM=$(curl -sf "$FORGEJO_URL/api/v1/repos/teleo/teleo-codex/pulls?state=open&head=teleo:$BRANCH&limit=1" \ - -H "Authorization: token $TOKEN" | python3 -c 'import sys,json; prs=json.load(sys.stdin); print(prs[0]["number"] if prs else "")' 2>/dev/null) + # Note: Forgejo head= filter is unreliable. Fetch all open PRs and filter locally. + PR_NUM=$(curl -sf "$FORGEJO_URL/api/v1/repos/teleo/teleo-codex/pulls?state=open&limit=50" \ + -H "Authorization: token $TOKEN" | python3 -c " +import sys,json +prs=json.load(sys.stdin) +branch='$BRANCH' +matches=[p for p in prs if p['head']['ref']==branch] +print(matches[0]['number'] if matches else '') +" 2>/dev/null) if [ -n "$PR_NUM" ]; then PR_MERGEABLE=$(curl -sf "$FORGEJO_URL/api/v1/repos/teleo/teleo-codex/pulls/$PR_NUM" \ -H "Authorization: token $TOKEN" | python3 -c 'import sys,json; print(json.load(sys.stdin).get("mergeable","true"))' 2>/dev/null)