Skip to content

branch regex is matched against {EscapedBranchName} not {BranchName} #4383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v6.2.0

* The configuration property `label-number-pattern` was removed. The functionality can be still used by changing the label and the branch name regular expression for pull-request branches.

## v6.0.0

### Platforms
Expand Down Expand Up @@ -60,7 +64,7 @@
* The `useBranchName` magic string has been removed. Instead use `{BranchName}` for `label`.

* The `BranchPrefixToTrim` configuration property has been removed. `RegularExpression` is now used to capture named groups instead.
* Default `RegularExpression` for feature branches is changed from `^features?[/-]` to `^features?[/-](?<BranchName>.+)` to support using `{BranchName}` out-of-the-box
* Default `RegularExpression` for feature branches is changed from `^features?[\/-]` to `^features?[\/-](?<BranchName>.+)` to support using `{BranchName}` out-of-the-box
* Default `RegularExpression` for unknown branches is changed from `.*` to `(?<BranchName>.+)` to support using `{BranchName}` out-of-the-box

* The `Mainline` mode and the related implementation has been removed completely. The new `Mainline` version strategy should be used instead.
Expand Down
167 changes: 87 additions & 80 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ branches:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-](?<BranchName>.+)
regex: ^releases?[\/-](?<BranchName>.+)
source-branches:
- main
- support
Expand All @@ -116,7 +116,7 @@ branches:
prevent-increment:
when-current-commit-tagged: false
track-merge-message: true
regex: ^features?[/-](?<BranchName>.+)
regex: ^features?[\/-](?<BranchName>.+)
source-branches:
- develop
- main
Expand All @@ -128,14 +128,13 @@ branches:
pre-release-weight: 30000
pull-request:
mode: ContinuousDelivery
label: PullRequest
label: PullRequest{Number}
increment: Inherit
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
label-number-pattern: '[/-](?<number>\d+)'
track-merge-message: true
regex: ^(pull|pull\-requests|pr)[/-]
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
source-branches:
- develop
- main
Expand All @@ -151,7 +150,7 @@ branches:
increment: Inherit
prevent-increment:
when-current-commit-tagged: false
regex: ^hotfix(es)?[/-](?<BranchName>.+)
regex: ^hotfix(es)?[\/-](?<BranchName>.+)
source-branches:
- main
- support
Expand All @@ -165,7 +164,7 @@ branches:
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^support[/-](?<BranchName>.+)
regex: ^support[\/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
Expand Down Expand Up @@ -209,7 +208,7 @@ tracks-release-branches: false
is-release-branch: false
is-main-branch: false
```
<sup><a href='/docs/workflows/GitFlow/v1.yml#L1-L167' title='Snippet source file'>snippet source</a> | <a href='#snippet-/docs/workflows/GitFlow/v1.yml' title='Start of snippet'>anchor</a></sup>
<sup><a href='/docs/workflows/GitFlow/v1.yml#L1-L166' title='Snippet source file'>snippet source</a> | <a href='#snippet-/docs/workflows/GitFlow/v1.yml' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The supported built-in configuration for the `GitHubFlow` workflow (`workflow: GitHubFlow/v1`) looks like:
Expand Down Expand Up @@ -262,7 +261,7 @@ branches:
when-current-commit-tagged: false
track-merge-target: false
track-merge-message: true
regex: ^releases?[/-](?<BranchName>.+)
regex: ^releases?[\/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
Expand All @@ -277,7 +276,7 @@ branches:
prevent-increment:
when-current-commit-tagged: false
track-merge-message: true
regex: ^features?[/-](?<BranchName>.+)
regex: ^features?[\/-](?<BranchName>.+)
source-branches:
- main
- release
Expand All @@ -286,14 +285,13 @@ branches:
pre-release-weight: 30000
pull-request:
mode: ContinuousDelivery
label: PullRequest
label: PullRequest{Number}
increment: Inherit
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
label-number-pattern: '[/-](?<number>\d+)'
track-merge-message: true
regex: ^(pull|pull\-requests|pr)[/-]
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
source-branches:
- main
- release
Expand Down Expand Up @@ -334,7 +332,7 @@ tracks-release-branches: false
is-release-branch: false
is-main-branch: false
```
<sup><a href='/docs/workflows/GitHubFlow/v1.yml#L1-L116' title='Snippet source file'>snippet source</a> | <a href='#snippet-/docs/workflows/GitHubFlow/v1.yml' title='Start of snippet'>anchor</a></sup>
<sup><a href='/docs/workflows/GitHubFlow/v1.yml#L1-L115' title='Snippet source file'>snippet source</a> | <a href='#snippet-/docs/workflows/GitHubFlow/v1.yml' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The preview built-in configuration (experimental usage only) for the `TrunkBased` workflow (`workflow: TrunkBased/preview1`) looks like:
Expand Down Expand Up @@ -381,7 +379,7 @@ branches:
prevent-increment:
when-current-commit-tagged: false
track-merge-message: true
regex: ^features?[/-](?<BranchName>.+)
regex: ^features?[\/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
Expand All @@ -393,7 +391,7 @@ branches:
increment: Patch
prevent-increment:
when-current-commit-tagged: false
regex: ^hotfix(es)?[/-](?<BranchName>.+)
regex: ^hotfix(es)?[\/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
Expand All @@ -402,14 +400,13 @@ branches:
pre-release-weight: 30000
pull-request:
mode: ContinuousDelivery
label: PullRequest
label: PullRequest{Number}
increment: Inherit
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
label-number-pattern: '[/-](?<number>\d+)'
track-merge-message: true
regex: ^(pull|pull\-requests|pr)[/-]
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
source-branches:
- main
- feature
Expand Down Expand Up @@ -444,7 +441,7 @@ tracks-release-branches: false
is-release-branch: false
is-main-branch: false
```
<sup><a href='/docs/workflows/TrunkBased/preview1.yml#L1-L101' title='Snippet source file'>snippet source</a> | <a href='#snippet-/docs/workflows/TrunkBased/preview1.yml' title='Start of snippet'>anchor</a></sup>
<sup><a href='/docs/workflows/TrunkBased/preview1.yml#L1-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-/docs/workflows/TrunkBased/preview1.yml' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The details of the available options are as follows:
Expand Down Expand Up @@ -664,77 +661,84 @@ If you have branch specific configuration upgrading to v4 will force you to
upgrade.

```yaml
workflow: 'GitHubFlow/v1'
branches:
main:
regex: ^master$|^main$
mode: ContinuousDelivery
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
prevent-increment:
of-merged-branch: true
track-merge-target: false
source-branches: [ 'develop', 'release' ]
track-merge-message: true
regex: ^master$|^main$
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
develop:
regex: ^dev(elop)?(ment)?$
mode: ContinuousDeployment
label: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
source-branches: []
tracks-release-branches: true
is-release-branch: false
is-main-branch: false
pre-release-weight: 0
release:
regex: ^releases?[/-]
mode: ContinuousDelivery
mode: ManualDeployment
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
increment: Patch
prevent-increment:
of-merged-branch: true
when-branch-merged: false
when-current-commit-tagged: false
track-merge-target: false
source-branches: [ 'develop', 'main', 'support', 'release' ]
track-merge-message: true
regex: ^releases?[\/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: true
is-main-branch: false
pre-release-weight: 30000
feature:
regex: ^features?[/-]
mode: ContinuousDelivery
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
prevent-increment:
when-current-commit-tagged: false
track-merge-message: true
regex: ^features?[\/-](?<BranchName>.+)
source-branches:
- main
- release
is-source-branch-for: []
is-main-branch: false
pre-release-weight: 30000
pull-request:
regex: ^(pull|pull\-requests|pr)[/-]
mode: ContinuousDelivery
label: PullRequest
label: PullRequest{Number}
increment: Inherit
label-number-pattern: '[/-](?<number>\d+)[-/]'
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-message: true
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
source-branches:
- main
- release
- feature
is-source-branch-for: []
pre-release-weight: 30000
hotfix:
regex: ^hotfix(es)?[/-]
mode: ContinuousDelivery
label: beta
unknown:
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
source-branches: [ 'release', 'main', 'support', 'hotfix' ]
pre-release-weight: 30000
support:
regex: ^support[/-]
mode: ContinuousDelivery
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
source-branches: [ 'main' ]
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
prevent-increment:
when-current-commit-tagged: false
track-merge-message: false
regex: (?<BranchName>.+)
source-branches:
- main
- release
- feature
- pull-request
is-source-branch-for: []
is-main-branch: false
```

If you don't specify the regex, the built-in for that branch config will be
Expand Down Expand Up @@ -840,9 +844,9 @@ The pre-release label to use for this branch. Use the value `{BranchName}` as a
insert the value of the named group `BranchName` from the [regular expression](#regex).

For example: branch `feature/foo` would become a pre-release label
of `alpha.foo` with `label: 'alpha.{BranchName}'` and `regex: '^features?[/-](?<BranchName>.+)'`.
of `alpha.foo` with `label: 'alpha.{BranchName}'` and `regex: '^features?[\/-](?<BranchName>.+)'`.

Another example: branch `features/sc-12345/some-description` would become a pre-release label of `sc-12345` with `label: '{StoryNo}'` and `regex: '^features?[/-](?<StoryNo>sc-\d+)[-/].+'`.
Another example: branch `features/sc-12345/some-description` would become a pre-release label of `sc-12345` with `label: '{StoryNo}'` and `regex: '^features?[\/-](?<StoryNo>sc-\d+)[-/].+'`.

**Note:** To clear a default use an empty string: `label: ''`

Expand Down Expand Up @@ -874,25 +878,28 @@ This branch related property controls the behvior whether to use the tagged (val
### label-number-pattern

Pull requests require us to extract the pre-release number out of the branch
name so `refs/pulls/534/merge` builds as `PullRequest.534`. This is a regex with
a named capture group called `number`.

If the branch `mode` is set to `ContinuousDeployment`, then the extracted
`number` is appended to the name of the pre-release label and the number portion
is the number of commits since the last label. This enables consecutive commits to
the pull request branch to generate unique full semantic version numbers when
the branch is configured to use ContinuousDeployment mode.
name so `refs/pull/534/merge` builds as `PullRequest534`. This is a regex with
a named capture group called `Number`.

**Example usage:**

```yaml
branches:
pull-request:
mode: ContinuousDeployment
label: PullRequest
mode: ContinuousDelivery
label: PullRequest{Number}
increment: Inherit
track-merge-target: true
label-number-pattern: '[/-](?<number>\d+)[-/]'
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-message: true
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
source-branches:
- main
- release
- feature
is-source-branch-for: []
pre-release-weight: 30000
```

### track-merge-target
Expand Down
Loading