Skip to content

Allow backport command without 'to' - #17361

Merged
akoeplinger merged 3 commits into
mainfrom
ievangelist-flexible-backport-syntax
Aug 18, 2026
Merged

akoeplinger merged 3 commits into
mainfrom
ievangelist-flexible-backport-syntax

Conversation

@IEvangelist

@IEvangelist IEvangelist commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Allow the reusable backport workflow to recognize both supported command forms:

  • /backport to release/13.5
  • /backport release/13.5

Aspire 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 to optional in the parser. The job condition now matches the parser's existing requirement that the command begin the comment.

Validation

  • Parsed .github/workflows/backport-base.yml successfully with PyYAML.
  • Exercised the embedded JavaScript regex against eight focused cases, including both accepted forms, supported branch-name characters, missing target rejection for /backport to and /backport to , and a command not at the start of the comment.
  • Ran git diff --check.

To double check:

Copilot AI lite review requested due to automatic review settings August 18, 2026 13:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_backport job condition to trigger when the comment body starts with /backport .
  • Make the JavaScript branch-extraction regex accept an optional to keyword.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/backport-base.yml Resolved
Copilot AI review requested due to automatic review settings August 18, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comment thread .github/workflows/backport-base.yml Resolved
…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]>
Copilot AI review requested due to automatic review settings August 18, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /m flag means ^ can match at the start of any line in a multi-line comment, so a comment like some text\n/backport release/13.5 will be accepted even though the PR description says the command must begin the comment. Dropping m keeps the old “must start the comment” behavior while still allowing the optional to keyword.
          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 ') }}

@IEvangelist
IEvangelist marked this pull request as ready for review August 18, 2026 16:35
@akoeplinger
akoeplinger requested a balanced review from Copilot August 18, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /backport anywhere in the comment, so text such as please use /backport release/13.5 starts the job even though the parser rejects it and the PR explicitly requires the command to begin the comment. Use startsWith so 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 to optional: \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 to when the target branch itself is named to. Separate the optional-keyword decision from the capture so bare to remains invalid without excluding it as an explicit target.
          const regex = /^\s*\/backport (?:to )?((?!to(?:\s|$))[a-zA-Z\d\/\.\-\_]+)/m;

@akoeplinger
akoeplinger merged commit 17a8e2a into main Aug 18, 2026
4 of 8 checks passed
@akoeplinger
akoeplinger deleted the ievangelist-flexible-backport-syntax branch August 18, 2026 18:09
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 19, 2026
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.

3 participants