Skip to content

Commit f3a5bed

Browse files
committed
fix(weekly): test the newest approval for staleness, not any stale one
1 parent 6281a54 commit f3a5bed

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

  • plugins/tend-ci-runner/skills/weekly

‎plugins/tend-ci-runner/skills/weekly/SKILL.md‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,23 @@ If no dependency PRs are open, note "0 dependency PRs to process" and continue t
6363
REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
6464
LAST_FORCE_PUSH_AT=$(gh api --paginate "repos/$REPO/issues/<number>/timeline" \
6565
| jq -rs 'add | [.[] | select(.event == "head_ref_force_pushed") | .created_at] | max // ""')
66+
# `last` BEFORE the staleness test, not after: the question is whether the
67+
# newest approval is stale, not whether some stale approval exists. Filtering
68+
# first would return the pre-rewrite id even when a later approval already
69+
# superseded it — dismissing a review that no longer sets the PR's state
70+
# while the one that does stands untouched.
6671
STALE_APPROVAL_ID=$(gh api --paginate "repos/$REPO/pulls/<number>/reviews" \
6772
| jq -rs --arg bot "$BOT_LOGIN" --arg fp "$LAST_FORCE_PUSH_AT" \
68-
'add | [.[] | select(.user.login == $bot and .state == "APPROVED")
69-
| select($fp != "" and .submitted_at < $fp)]
70-
| last | .id // empty')
73+
'add | [.[] | select(.user.login == $bot and .state == "APPROVED")]
74+
| last
75+
| select(. != null and $fp != "" and .submitted_at < $fp)
76+
| .id')
7177

7278
if [ -n "$STALE_APPROVAL_ID" ]; then
73-
# PUT, not POST — the dismiss endpoint requires it.
79+
# PUT, not POST — the dismiss endpoint requires it. Keep the message to what
80+
# these paths actually do: they comment and stop, so don't promise a re-review.
7481
gh api "repos/$REPO/pulls/<number>/reviews/$STALE_APPROVAL_ID/dismissals" \
75-
-X PUT -f message="Rebased since this approval; re-reviewing."
82+
-X PUT -f message="Rebased since this approval; the new head is unreviewed."
7683
fi
7784
```
7885
A dismissed review reports `DISMISSED` rather than `APPROVED`, so the filter stops matching it and a later run re-dismisses nothing.

0 commit comments

Comments
 (0)