Commit fb24726
ci: label user-prefixed backport branches too (#15105)
## The workflow does not catch the branches it exists for
`pr-label-backport.yaml`'s header states its purpose plainly —
*"Guarantees that
every backport PR carries the `backport` label, **whoever opened it**"*
— and
explains that manual backports are the case that matters, because
`pr-backport.yaml` only labels the PRs it creates itself, and hands off
to a
human when the cherry-pick conflicts.
But `isBackportBranchForBase` matched only the exact branch the workflow
generates:
```ts
const BACKPORT_BRANCH_PATTERN = /^backport-\d+-to-(.+)$/
```
A human finishing a conflicted cherry-pick does not produce that. They
produce
`<user>/backport-<pr>-to-<target>` — what `gh` and most local branch
conventions give you.
## This week's worked example
**#15102** and **#15103** (`jaeone94/backport-14984-to-core-1.49` and
`…-cloud-1.49`) were opened by hand after `pr-backport.yaml` failed on
#14984's cherry-pick, and carry the `backport` label **only because
someone
applied it manually**.
That matters because an unlabelled backport is invisible to
`backport-auto-merge.yaml` and `pr-assign-release-sheriff.yaml` — both
sweep
`gh pr list --label backport` — so it sits open until somebody notices.
Which
is exactly what #14018–#14021 are cited for in the workflow's own
header.
Surveying every backport-titled PR in the repo: the bot's
`backport-<n>-to-<target>` branches are all labelled, and the only
user-prefixed pair is the one that needed a human.
## Only the prefix widens
```diff
-const BACKPORT_BRANCH_PATTERN = /^backport-\d+-to-(.+)$/
+const BACKPORT_BRANCH_PATTERN = /^(?:.*\/)?backport-\d+-to-(.+)$/
```
The `\d+-to-` core and the existing base check still decide what counts
as a
backport, so this does **not** loosen the definition:
| branch | base | before | after |
| --- | --- | --- | --- |
| `backport-14979-to-core-1.49` | `core/1.49` | ✅ | ✅ |
| `jaeone94/backport-14984-to-core-1.49` | `core/1.49` | ❌ | ✅ |
| `jaeone94/backport-14984-to-core-1.49` | `cloud/1.49` | ❌ | ❌ *(target
≠ base)* |
| `glary/backport-resilient-partial-failure` | `core/1.49` | ❌ | ❌ |
| `deepme987/infra/backport-assign-author` | `main` | ❌ | ❌ |
The last two are real branches in this repo — *about* backporting rather
than
backports. A prefix must not turn them into one, and it doesn't: they
have no
`<digits>-to-` segment.
## Verification
`backport-label.test.ts` **16/16**, with three new cases covering the
prefixed
form, the prefixed-but-wrong-base rejection, and the two real
non-backport
branches above.
Mutation-checked rather than asserted green — reverting the regex to
`^backport-`
fails exactly one test (the new prefixed case) and leaves the other 15
passing.
## Disclosure
I hit this myself from the other direction. My manual backports
#15095/#15096
used `backport/<pr>-to-<target>` — a **slash** where the convention uses
a
hyphen. That one is genuinely off-convention rather than a gap in the
rule, so
this PR deliberately does **not** widen the pattern to bless it; I fixed
those
branches' labels by hand instead.
Co-authored-by: t <t@t.t>1 parent 82bad2e commit fb24726
2 files changed
Lines changed: 54 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
96 | 136 | | |
97 | 137 | | |
98 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
35 | 48 | | |
36 | 49 | | |
37 | 50 | | |
| |||
0 commit comments