pr conflicts: bound the forge list and skip branches no pr targets
This commit is contained in:
parent
11eb7dac9c
commit
02f21940a4
1 changed files with 272 additions and 13 deletions
|
|
@ -218,20 +218,30 @@ it. With no head kept yet, it can't tell and sends the todo.
|
|||
**Merge conflicts as a source.** Forgejo sends no delivery when a push to a
|
||||
branch changes whether the PRs targeting it merge, and the router has no forge
|
||||
client. swarm-controller makes the event instead: on each `push` delivery on its
|
||||
instance-wide `push` hook, for a branch push that didn't delete the branch, it
|
||||
waits 30 seconds for the forge to recompute, then lists the open PRs that
|
||||
instance-wide `push` hook, for a push to the repo's default branch or to a branch the
|
||||
controller has seen an open PR target, it waits 30 seconds for the forge to
|
||||
recompute, then lists the open PRs that
|
||||
target the branch (one call per page of 50) and publishes one
|
||||
`pull_request_mergeability` event per PR to `$SWARM.events.forge`, where
|
||||
`action` is `conflicting` or `mergeable`. The body is a `pull_request`
|
||||
delivery, so `repo`, `number`, `title`, `url`, `author` and `assignees` read as
|
||||
for any PR.
|
||||
|
||||
The controller learns which branches PRs target from the `pull_request`
|
||||
deliveries it already handles, in memory: an opened, edited or reopened PR adds
|
||||
its base, a closed one drops it. A push to any other branch, such as an agent's
|
||||
topic branch, starts nothing. After a controller restart the set is empty, so the
|
||||
controller checks a PR that targets a branch other than the default, such as a
|
||||
stacked PR, again only from its next `pull_request` delivery. A forge call that
|
||||
gets no answer within two minutes ends the check with a log line, and the next
|
||||
push starts a new one.
|
||||
|
||||
Forgejo's `mergeable` flag is false for a conflict, for an error, for a draft
|
||||
and while the check still runs. The controller leaves drafts out and counts a
|
||||
PR as conflicting only when two reads 30 seconds apart both say false. A PR
|
||||
that reads undecided gets read again, up to four reads in all. One check runs
|
||||
per branch at a time; a push during it makes it run once more when it ends. A
|
||||
push to a branch with no open PR costs one list call. With open PRs that all
|
||||
push to the default branch costs one list call when no PR targets it. With open PRs that all
|
||||
merge it's still one; each PR that reads false or undecided adds a second read
|
||||
at least, and four is the most.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue