Close duplicate pull requests when an issue is fixed #18472

Merged
florian-lefebvre opened 5:46am on October 21, 2026 wanted to merge 277 Ξ” into withastro/astro main from
florian-lefebvre/Auto-close-duplicated-PRs

Pull Request Overview

  • Opened on October 21, 2026
  • Status Merged
  • Commit count 2 with first commit October 21, 2026

Total Delta

277 Total Diff Delta

Open Days

Open 15 weekdays

Test Delta

0 Diff Delta in Test Files
Breakdown by Phase

How long has this pull request spent in each phase of its lifecycle?

Fraction of total time Business days Phase
 
0.0 days Authoring 1 commit before pull request opened for review
 
0.0 days Awaiting first review
 
0.4 days Revising work with 1 commit in response to 3 reviews that left 9 comments
Set up deploy tracking to begin tracking full PR start-to-deploy times

Total time for pull request 0.4 business days from first commit authored to merge
Deploy tracking has not been set up

Author avatar

Close duplicate pull requests when an issue is fixed

Changes

Tries to make our life easier when it comes to PRs:


  • Adds a workflow that closes open pull requests when another pull request fixes every issue they close.

  • Runs after a merge and on a weekly sweep, so duplicates opened before this workflow are cleaned up too.

  • Skips drafts, pull requests from maintainers, and pull requests that also fix issues the merged change does not.

  • Comments with the merged fix and a path to reopen.

Testing


  • Ran the merge handler against #18419, which closed the duplicate #18358.

  • Ran the sweep against the live repository, which found #18064, #18324, #18338, #18358, and #18369.

  • Exercised pagination, deleted authors, reopened issues, partial supersets, permission failures, and state races with a stub harness.


  • zizmor --min-severity high --min-confidence high reports no findings.

  • Biome and Prettier checks pass.

Docs

No documentation changes. This is repository automation.

AI was used to write this change.

Comments Threads Pending Resolution

astro-factory[bot] reviewed on October 21, 2026
astro-factory[bot] left a comment

## Findings

- `[medium][correctness]` `.github/scripts/close-duplicate-prs.mjs:209`: The merge handler closes PRs without checking whether the linked issue is actually closed. Details are in the inline comment.

## Merge Requirement Assessment

Status: gaps found

- **Close open PRs when another merged PR fixes every issue they close.** `closeAfterMerge` and `sweep` implement this with a superset check (`every(... mergedIssues.has ...)` and `fixes.length === current.issues.length`). In the merge path, "fixes" depends on the merged PR's linked issues, not on whether those issues were actually closed (see finding).
- **Run after a merge and on a weekly sweep.** Covered by the `pull_request_target: closed` trigger with the `merged == true` guard, plus `schedule` and `workflow_dispatch`.
- **Skip drafts, maintainer PRs, and PRs that also fix issues the merged change doesn't.** Covered by the `isDraft` checks before and after the re-fetch, `isMaintainer` (which treats a deleted author or a failed permission lookup as a maintainer), and the subset checks.
- **Comment with the merged fix and a way to reopen.** Covered by `duplicateComment`, posted by `closeDuplicate` after the close.

## Review Status

Verdict: changes required
Context: PR #18472 description
Scope: PR base `e0d71824` to head `b5d0949a` (`.github/scripts/close-duplicate-prs.mjs`, `.github/workflows/close-duplicate-prs.yml`).
Changeset: not required (repository automation only).
Limitations: none. The workflow's security posture looks sound: `pull_request_target` checks out the base ref with `persist-credentials: false`, actions are pinned, no PR-controlled data is interpolated into the script, and permissions are scoped to the job.
Validation: Static review only; no project code, tests, builds, or checks were run.
GitHub context: collected
Git scope: PR base/head verified

*This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.*

.github/scripts/close-duplicate-prs.mjs

Resolved Comment Threads

ematipico reviewed on October 21, 2026
.github/workflows/close-duplicate-prs.yml
Outdated