sorenlouv / backport

A simple CLI tool that automates the process of backporting commits on a GitHub repo
https://github.com/sqren/backport/blob/main/docs/config-file-options.md
Apache License 2.0
241 stars 57 forks source link

Add support for dynamic target labels #400

Closed sorenlouv closed 2 years ago

sorenlouv commented 2 years ago

Closes https://github.com/sqren/backport/issues/391

Add support for dynamic values in targetPRLabels where the matched regex groups from branchLabelMapping can be used in the label in targetPRLabels.

Example: branchLabelMapping regex group matching (using $1, $2 etc)

// .backportrc.json
{
  "branchLabelMapping": {
    "^backport-to-(.+)$": "release/$1",
  },  
  "targetPRLabels": ["backported-to-$1"],
}

When a PR with the label backport-to-production is backported, the backport PR will target the branch "release/production", and have the label backported-to-production.

Example: Template variables using {targetBranch} and {sourceBranch}

It is also possible to have dynamic values using the template variables {targetBranch} and {sourceBranch}.

// .backportrc.json
{
  "targetPRLabels": ["backported-to-{targetBranch}-from-{sourceBranch}"],
}

In this case, a PR backported to "production" will get the label "backported-to-production-from-main". No labels needed in this case.

sorenlouv commented 2 years ago

Released in v8.7.0