Skip to content

Commit 6281a54

Browse files
committed
fix(weekly): dismiss a re-anchored approval on the comment-and-skip paths
1 parent 716a3f8 commit 6281a54

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ If no dependency PRs are open, note "0 dependency PRs to process" and continue t
5757
```
5858
4. If CI is failing, comment with the failure summary and skip
5959
5. If a major version bump, comment noting it needs manual review and skip
60+
6. On either skip path (4 or 5), dismiss an approval that predates the newest rewrite before you leave. Both paths are reachable *because* a rebase changed something, and neither passes through item 3's guard — so the pre-rewrite approval stays the bot's latest review, re-anchored onto the current head, and the PR still reads as bot-approved while you comment that it isn't mergeable:
61+
```bash
62+
BOT_LOGIN=$(gh api user --jq '.login')
63+
REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
64+
LAST_FORCE_PUSH_AT=$(gh api --paginate "repos/$REPO/issues/<number>/timeline" \
65+
| jq -rs 'add | [.[] | select(.event == "head_ref_force_pushed") | .created_at] | max // ""')
66+
STALE_APPROVAL_ID=$(gh api --paginate "repos/$REPO/pulls/<number>/reviews" \
67+
| 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')
71+
72+
if [ -n "$STALE_APPROVAL_ID" ]; then
73+
# PUT, not POST — the dismiss endpoint requires it.
74+
gh api "repos/$REPO/pulls/<number>/reviews/$STALE_APPROVAL_ID/dismissals" \
75+
-X PUT -f message="Rebased since this approval; re-reviewing."
76+
fi
77+
```
78+
A dismissed review reports `DISMISSED` rather than `APPROVED`, so the filter stops matching it and a later run re-dismisses nothing.
6079

6180
## Step 3: Repo-specific weekly tasks
6281

0 commit comments

Comments
 (0)