Skip to content

Label the original PR once a backport lands - #74

Draft
aiolibsbot wants to merge 1 commit into
sanitizers:masterfrom
aiolibsbot:koan/backport-label-lifecycle
Draft

aiolibsbot wants to merge 1 commit into
sanitizers:masterfrom
aiolibsbot:koan/backport-label-lifecycle

Conversation

@aiolibsbot

@aiolibsbot aiolibsbot commented Sep 16, 2026 •

Copy link
Copy Markdown

What

Two off-by-default repo config options that update the original PR's labels once a backport PR is created: backported_label_prefix adds <prefix><branch_id>, delete_backport_label_on_success removes the triggering backport-<branch_id>.

Why

Refs #12. A merged PR looks identical whether the backport landed or the cherry-pick conflicted — the backport-X label stays either way, so finding the ones that still need a human means opening each and reading its check runs. Setting both options leaves backport-X on exactly the PRs that need manual work.

How

  • Label recognition moved into a pure patchback/labels.py. Both prefixes are configurable, so a repo can pick a completion prefix that extends the trigger one — backport/backported does, the defaults backport-/backported- do not. Where it does, the success label would read as a fresh backport request and the App would trigger itself; is_backport_label() rules that out.
  • patchback/labels_api.py follows the existing *_api.py wrapper pattern. remove_label() percent-encodes the label into the path — backport-stable/2.0 would otherwise become extra path segments.
  • Label writes are best-effort: the backport PR already exists by then, so a failed write is logged, not reported as a failed backport.
  • No manifest change — pull_requests: write already covers PR labels.
  • Defaults ('' / False) keep today's behaviour byte-for-byte.

Testing

18 tests in tests/test_labels.py and tests/test_labels_api.py, covering prefix collision, the feature-off path, and path escaping. They are stdlib-only and run under bare pytest tests/; wiring them into CI depends on the tests.yml workflow from #72.


Quality Report

Changes: 6 files changed, 292 insertions(+), 10 deletions(-)

Code scan: clean

Tests: skipped

Branch hygiene: clean

Generated by Kōan

Nothing on a merged pull request distinguishes a backport that the App
created from one that it gave up on -- the `backport-X` label stays put
either way. Maintainers looking for the branches that still need a hand
have to open every labeled PR and read its check runs.

Add two independent, off-by-default repo config options:
`backported_label_prefix` labels the original PR with
`<prefix><branch_id>` once the backport PR exists, and
`delete_backport_label_on_success` drops the label that triggered the
run. Setting both leaves `backport-X` on exactly the pull requests that
still need manual work.

Both prefixes are configurable, so a repo can pick a completion prefix
that extends the trigger one -- `backport`/`backported` does, the
defaults do not. There, the label added on success would read as another
backport request and the App would trigger itself, so label recognition
moves into `is_backport_label()` which rules that out.

Writing the labels is best-effort: the backport PR already exists by the
time it runs, and a failing label write must not report the backport as
failed.

Refs sanitizers#12

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant