Repository navigation
Mark PRs with merge conflicts stale on a shorter window - #186
Conversation
A PR whose head conflicts with the base branch cannot be merged, and merging the base branch is a small ask, so it does not need the full inactivity window before it is marked stale. A new days-before-stale-conflicting input sets a shorter window for such PRs (0, the default, keeps the general window), with its own comment. A conflict-label (needs-rebase by default) is added with the stale label. While it is present, comments do not unmark the PR: only resolving the conflicts does. Once the PR is mergeable again the conflict label is removed and the usual activity check applies, which the resolving commit satisfies. Mergeability is computed lazily by GitHub, so a PR whose state is not known yet is neither marked nor closed on that run. The pulls.get response is cached per run since the head-commit check uses it too.
A PR is now told about its merge conflicts as soon as they are detected: the conflict label is added with a comment asking for the base branch to be merged. If the label is still present after days-before-stale-conflicting the PR is marked stale regardless of other activity, and closed after days-before-close unless the conflicts are resolved. The conflict label is removed as soon as the PR is mergeable again. Also wraps the two log lines yamllint flagged for length.
|
ESPHome Bot (@esphbot) review |
|
|
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Warning
Important issues found.
- Conflict rules for stale PRs run even when conflict handling is disabled
- A conflicting PR can be marked stale with a message that says commenting keeps it open, but commenting no longer does
The stale-phase conflict rules now also require days-before-stale-conflicting to be set, so callers that do not opt in keep today's behaviour even when the conflict label exists in their repo. A PR that reaches the ordinary inactivity mark while carrying the conflict label gets the conflict message, since a comment will not keep it open. A stale PR that becomes mergeable again is unmarked directly, as the conflict comment promises, instead of depending on a new commit. The helpers move above the activity rationale comment.
|
|
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
The first pulls.get after the base branch moved returns mergeable null and only starts the merge test, so a run made shortly after a push to the base branch skipped those PRs until the next day. A null result is now fetched again after three seconds, up to twice, before the PR is treated as unknown.
|
ESPHome Bot (@esphbot) review |
|
|
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Fetching every PR before the main loop starts all of GitHub's merge tests at once, so one wait covers them all; the per-PR retry could have slept for most of the open PRs after a push to the base branch. Stale PRs with unknown mergeability now count in the run summary, and a PR whose conflict label was just removed no longer gets the conflict message if the inactivity check marks it stale on the same run.
|
ESPHome Bot (@esphbot) review |
PR Review — Mark PRs with merge conflicts stale on a shorter windowReady to merge. Both suggestions from the last review are fixed, and I found no new issues. What the PR does well:
Resolved since the last review:
✅ Resolved since last review (2)Previously-flagged issues verified fixed
Checklist
Automated review by Kōan (Claude) |
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
|
Thanks |
What
A PR whose head conflicts with its base cannot be merged, and merging the base branch is a small ask, so the stale workflow now handles it in three steps:
needs-rebaseby default).days-before-stale-conflictingdays, the PR is marked stale with its own comment, regardless of other activity on it.days-before-closeit is closed unless the conflicts have been resolved. While the conflict label is present a comment does not unmark the PR; only becoming mergeable does, at which point both labels are removed.New inputs, all optional so existing callers are unaffected:
days-before-stale-conflicting(0, the default, disables conflict handling entirely, including the rules above for PRs that already carry the label),conflict-label,conflict-pr-message,stale-conflicting-pr-message.Why
On esphome/esphome right now 167 of 484 open PRs have merge conflicts, 74 of them with no activity for over 30 days. None of them are stale because the 90-day clock keeps being reset, and nobody tells the author until that clock runs out.
How
Mergeability comes from
pulls.get. GitHub computes it lazily: the first request after the base branch moved returnsmergeable: nulland only starts the merge test. Every open PR is therefore fetched before the main loop, so the tests run in parallel, and the undecided ones are fetched again after one wait, up to twice. A PR still unknown after that, or whose lookup failed, is neither labelled, marked nor closed on that run and is counted in the summary.dirtyis the onlymergeable_statethat means conflicts;behind,blockedandunstabledo not. The label date comes from the issue events, the same way the stale label date already does, so a conflict label applied by hand starts the clock too.Cost: one
pulls.getper open PR per run when conflict handling is enabled, cached so the head-commit check reuses it, plus one events listing per conflict-labelled PR.Dry runs against esphome/esphome
Caller branch pinned to this PR: esphome/esphome@stale-merge-conflicts. Two dry runs (actions runs 38057476825 and 38058628433) each processed 774 open items in about 5 minutes and would have labelled the same 156 PRs, every one of them conflicting per the API, with no errors. The other 11 conflicting PRs are either exempt (
not-stale) or already stale, where the conflict label is not added. The first live run therefore comments on and labels about 156 PRs at once.