Merge pull request 'fix: Dual curl calls for HAS_APPROVE / HAS_CHANGES create a race window (#321)' (#335) from fix/issue-321 into main
This commit is contained in:
commit
7d03f2c9ee
1 changed files with 15 additions and 13 deletions
|
|
@ -275,12 +275,12 @@ if [ "$ORPHAN_COUNT" -gt 0 ]; then
|
||||||
log "PR #${HAS_PR} has no code files — treating CI as passed"
|
log "PR #${HAS_PR} has no code files — treating CI as passed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check formal reviews
|
# Check formal reviews (single fetch to avoid race window)
|
||||||
HAS_APPROVE=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
REVIEWS_JSON=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
||||||
"${API}/pulls/${HAS_PR}/reviews" | \
|
"${API}/pulls/${HAS_PR}/reviews") || true
|
||||||
|
HAS_APPROVE=$(echo "$REVIEWS_JSON" | \
|
||||||
jq -r '[.[] | select(.state == "APPROVED") | select(.stale == false)] | length') || true
|
jq -r '[.[] | select(.state == "APPROVED") | select(.stale == false)] | length') || true
|
||||||
HAS_CHANGES=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
HAS_CHANGES=$(echo "$REVIEWS_JSON" | \
|
||||||
"${API}/pulls/${HAS_PR}/reviews" | \
|
|
||||||
jq -r '[.[] | select(.state == "REQUEST_CHANGES")] | length') || true
|
jq -r '[.[] | select(.state == "REQUEST_CHANGES")] | length') || true
|
||||||
|
|
||||||
if ci_passed "$CI_STATE" && [ "${HAS_APPROVE:-0}" -gt 0 ]; then
|
if ci_passed "$CI_STATE" && [ "${HAS_APPROVE:-0}" -gt 0 ]; then
|
||||||
|
|
@ -355,11 +355,12 @@ for i in $(seq 0 $(($(echo "$OPEN_PRS" | jq 'length') - 1))); do
|
||||||
log "PR #${PR_NUM} has no code files — treating CI as passed"
|
log "PR #${PR_NUM} has no code files — treating CI as passed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HAS_CHANGES=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
# Single fetch to avoid race window between review checks
|
||||||
"${API}/pulls/${PR_NUM}/reviews" | \
|
REVIEWS_JSON=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
||||||
|
"${API}/pulls/${PR_NUM}/reviews") || true
|
||||||
|
HAS_CHANGES=$(echo "$REVIEWS_JSON" | \
|
||||||
jq -r '[.[] | select(.state == "REQUEST_CHANGES")] | length') || true
|
jq -r '[.[] | select(.state == "REQUEST_CHANGES")] | length') || true
|
||||||
HAS_APPROVE=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
HAS_APPROVE=$(echo "$REVIEWS_JSON" | \
|
||||||
"${API}/pulls/${PR_NUM}/reviews" | \
|
|
||||||
jq -r '[.[] | select(.state == "APPROVED") | select(.stale == false)] | length') || true
|
jq -r '[.[] | select(.state == "APPROVED") | select(.stale == false)] | length') || true
|
||||||
|
|
||||||
# Spawn agent to merge if approved + CI green
|
# Spawn agent to merge if approved + CI green
|
||||||
|
|
@ -443,11 +444,12 @@ for i in $(seq 0 $((BACKLOG_COUNT - 1))); do
|
||||||
log "PR #${EXISTING_PR} has no code files — treating CI as passed"
|
log "PR #${EXISTING_PR} has no code files — treating CI as passed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HAS_APPROVE=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
# Single fetch to avoid race window between review checks
|
||||||
"${API}/pulls/${EXISTING_PR}/reviews" | \
|
REVIEWS_JSON=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
||||||
|
"${API}/pulls/${EXISTING_PR}/reviews") || true
|
||||||
|
HAS_APPROVE=$(echo "$REVIEWS_JSON" | \
|
||||||
jq -r '[.[] | select(.state == "APPROVED") | select(.stale == false)] | length') || true
|
jq -r '[.[] | select(.state == "APPROVED") | select(.stale == false)] | length') || true
|
||||||
HAS_CHANGES=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" \
|
HAS_CHANGES=$(echo "$REVIEWS_JSON" | \
|
||||||
"${API}/pulls/${EXISTING_PR}/reviews" | \
|
|
||||||
jq -r '[.[] | select(.state == "REQUEST_CHANGES")] | length') || true
|
jq -r '[.[] | select(.state == "REQUEST_CHANGES")] | length') || true
|
||||||
|
|
||||||
if ci_passed "$CI_STATE" && [ "${HAS_APPROVE:-0}" -gt 0 ]; then
|
if ci_passed "$CI_STATE" && [ "${HAS_APPROVE:-0}" -gt 0 ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue