Repository navigation
Allow backport command without 'to' - #17361
Conversation
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR updates the reusable backport workflow so it triggers and parses both supported command forms (/backport to <branch> and /backport <branch>), aligning the job trigger condition with the branch parser’s “command must start the comment” requirement.
Changes:
- Update the
run_backportjob condition to trigger when the comment body starts with/backport. - Make the JavaScript branch-extraction regex accept an optional
tokeyword.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <[email protected]>
…s own line - Restore contains(...) for the run_backport condition so the job still triggers when the /backport command is preceded by whitespace, newlines, or a reply in the same comment (per @akoeplinger's feedback). - Make the branch-extraction regex multiline and tolerate leading whitespace so extraction succeeds for those same comments instead of throwing, while still rejecting a bare 'to' target. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
.github/workflows/backport-base.yml:64
- The
/mflag means^can match at the start of any line in a multi-line comment, so a comment likesome text\n/backport release/13.5will be accepted even though the PR description says the command must begin the comment. Droppingmkeeps the old “must start the comment” behavior while still allowing the optionaltokeyword.
const regex = /^\s*\/backport (?:to )?((?!to(?:\s|$))[a-zA-Z\d\/\.\-\_]+)/m;
.github/workflows/backport-base.yml:48
- The job-level condition is too permissive:
contains(github.event.comment.body, '/backport ')will start this workflow for any comment that merely mentions the command (e.g. documentation/quoting), even when the extractor regex won’t match at the start of the comment. That can create noisy failing runs (or unintended backports if the regex matches a later line). Prefer gating on the command actually starting the comment.
This issue also appears on line 64 of the same file.
if: ${{ contains(format('{0},', inputs.repository_owners), format('{0},', github.repository_owner)) && github.event.issue.pull_request != '' && contains(github.event.comment.body, '/backport ') }}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
.github/workflows/backport-base.yml:48
- This condition still accepts
/backportanywhere in the comment, so text such asplease use /backport release/13.5starts the job even though the parser rejects it and the PR explicitly requires the command to begin the comment. UsestartsWithso invalid prose does not launch a failing workflow.
if: ${{ contains(format('{0},', inputs.repository_owners), format('{0},', github.repository_owner)) && github.event.issue.pull_request != '' && contains(github.event.comment.body, '/backport ') }}
.github/workflows/backport-base.yml:64
- This pattern introduces two regressions beyond making
tooptional:\s*plus the multiline flag accepts commands on later lines, despite the stated start-of-comment requirement, and the capture-wide negative lookahead rejects the previously valid long form/backport to towhen the target branch itself is namedto. Separate the optional-keyword decision from the capture so baretoremains invalid without excluding it as an explicit target.
const regex = /^\s*\/backport (?:to )?((?!to(?:\s|$))[a-zA-Z\d\/\.\-\_]+)/m;
Summary
Allow the reusable backport workflow to recognize both supported command forms:
/backport to release/13.5/backport release/13.5Aspire maintainers commonly use the shorter form. Previously, it silently did not start the reusable workflow because both the job condition and branch parser required the literal middle word
to.This keeps the existing syntax and behavior while making
tooptional in the parser. The job condition now matches the parser's existing requirement that the command begin the comment.Validation
.github/workflows/backport-base.ymlsuccessfully with PyYAML./backport toand/backport to, and a command not at the start of the comment.git diff --check.To double check: