From 17907063f6c02d443e37d963dd5dfc25bea68618 Mon Sep 17 00:00:00 2001 From: openhands Date: Thu, 19 Mar 2026 01:25:44 +0000 Subject: [PATCH] fix: codeberg_api_all does not accept a custom token parameter (#198) Add optional second TOKEN parameter to codeberg_api_all in lib/env.sh, defaulting to $CODEBERG_TOKEN. Pass $REVIEW_BOT_TOKEN at the dismiss block in review-pr.sh so reviews are fetched as the review bot account. Co-Authored-By: Claude Sonnet 4.6 --- lib/env.sh | 2 ++ review/review-pr.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/env.sh b/lib/env.sh index a1150e8..505d14e 100755 --- a/lib/env.sh +++ b/lib/env.sh @@ -60,8 +60,10 @@ codeberg_api() { # Paginate a Codeberg API GET endpoint and return all items as a merged JSON array. # Usage: codeberg_api_all /path (no existing query params) # codeberg_api_all /path?a=b (with existing params — appends &limit=50&page=N) +# codeberg_api_all /path TOKEN (optional second arg: token; defaults to $CODEBERG_TOKEN) codeberg_api_all() { local path_prefix="$1" + local CODEBERG_TOKEN="${2:-${CODEBERG_TOKEN}}" local sep page page_items count all_items="[]" case "$path_prefix" in *"?"*) sep="&" ;; diff --git a/review/review-pr.sh b/review/review-pr.sh index 84a7aa1..a2a2ac0 100755 --- a/review/review-pr.sh +++ b/review/review-pr.sh @@ -759,7 +759,7 @@ if [ "${POST_CODE}" = "201" ]; then REVIEW_BOT_LOGIN=$(printf '%s' "$REVIEW_BOT_RESP" | jq -r '.login // empty') fi if [ -n "$REVIEW_BOT_LOGIN" ]; then - ALL_PR_REVIEWS=$(codeberg_api_all "/pulls/${PR_NUMBER}/reviews" || echo "[]") + ALL_PR_REVIEWS=$(codeberg_api_all "/pulls/${PR_NUMBER}/reviews" "$REVIEW_BOT_TOKEN" || echo "[]") while IFS= read -r review_id; do DISMISS_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ -X POST \