Skip to content

Commit f977f68

Browse files
committed
branch regex is matched against {EscapedBranchName} not {BranchName} +semver minor
1 parent d3db023 commit f977f68

28 files changed

+105
-181
lines changed

BREAKING_CHANGES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v6.1.0
2+
3+
* 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.
4+
15
## v6.0.0
26

37
### Platforms
@@ -60,7 +64,7 @@
6064
* The `useBranchName` magic string has been removed. Instead use `{BranchName}` for `label`.
6165
6266
* The `BranchPrefixToTrim` configuration property has been removed. `RegularExpression` is now used to capture named groups instead.
63-
* Default `RegularExpression` for feature branches is changed from `^features?[/-]` to `^features?[/-](?<BranchName>.+)` to support using `{BranchName}` out-of-the-box
67+
* Default `RegularExpression` for feature branches is changed from `^features?[\/-]` to `^features?[\/-](?<BranchName>.+)` to support using `{BranchName}` out-of-the-box
6468
* Default `RegularExpression` for unknown branches is changed from `.*` to `(?<BranchName>.+)` to support using `{BranchName}` out-of-the-box
6569
6670
* The `Mainline` mode and the related implementation has been removed completely. The new `Mainline` version strategy should be used instead.

docs/input/docs/reference/configuration.md

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ branches:
100100
of-merged-branch: true
101101
when-current-commit-tagged: false
102102
track-merge-target: false
103-
regex: ^releases?[/-](?<BranchName>.+)
103+
regex: ^releases?[\/-](?<BranchName>.+)
104104
source-branches:
105105
- main
106106
- support
@@ -116,7 +116,7 @@ branches:
116116
prevent-increment:
117117
when-current-commit-tagged: false
118118
track-merge-message: true
119-
regex: ^features?[/-](?<BranchName>.+)
119+
regex: ^features?[\/-](?<BranchName>.+)
120120
source-branches:
121121
- develop
122122
- main
@@ -128,14 +128,13 @@ branches:
128128
pre-release-weight: 30000
129129
pull-request:
130130
mode: ContinuousDelivery
131-
label: PullRequest
131+
label: PullRequest{Number}
132132
increment: Inherit
133133
prevent-increment:
134134
of-merged-branch: true
135135
when-current-commit-tagged: false
136-
label-number-pattern: '[/-](?<number>\d+)'
137136
track-merge-message: true
138-
regex: ^(pull|pull\-requests|pr)[/-]
137+
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
139138
source-branches:
140139
- develop
141140
- main
@@ -151,7 +150,7 @@ branches:
151150
increment: Inherit
152151
prevent-increment:
153152
when-current-commit-tagged: false
154-
regex: ^hotfix(es)?[/-](?<BranchName>.+)
153+
regex: ^hotfix(es)?[\/-](?<BranchName>.+)
155154
source-branches:
156155
- main
157156
- support
@@ -165,7 +164,7 @@ branches:
165164
prevent-increment:
166165
of-merged-branch: true
167166
track-merge-target: false
168-
regex: ^support[/-](?<BranchName>.+)
167+
regex: ^support[\/-](?<BranchName>.+)
169168
source-branches:
170169
- main
171170
is-source-branch-for: []
@@ -262,7 +261,7 @@ branches:
262261
when-current-commit-tagged: false
263262
track-merge-target: false
264263
track-merge-message: true
265-
regex: ^releases?[/-](?<BranchName>.+)
264+
regex: ^releases?[\/-](?<BranchName>.+)
266265
source-branches:
267266
- main
268267
is-source-branch-for: []
@@ -277,7 +276,7 @@ branches:
277276
prevent-increment:
278277
when-current-commit-tagged: false
279278
track-merge-message: true
280-
regex: ^features?[/-](?<BranchName>.+)
279+
regex: ^features?[\/-](?<BranchName>.+)
281280
source-branches:
282281
- main
283282
- release
@@ -286,14 +285,13 @@ branches:
286285
pre-release-weight: 30000
287286
pull-request:
288287
mode: ContinuousDelivery
289-
label: PullRequest
288+
label: PullRequest{Number}
290289
increment: Inherit
291290
prevent-increment:
292291
of-merged-branch: true
293292
when-current-commit-tagged: false
294-
label-number-pattern: '[/-](?<number>\d+)'
295293
track-merge-message: true
296-
regex: ^(pull|pull\-requests|pr)[/-]
294+
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
297295
source-branches:
298296
- main
299297
- release
@@ -381,7 +379,7 @@ branches:
381379
prevent-increment:
382380
when-current-commit-tagged: false
383381
track-merge-message: true
384-
regex: ^features?[/-](?<BranchName>.+)
382+
regex: ^features?[\/-](?<BranchName>.+)
385383
source-branches:
386384
- main
387385
is-source-branch-for: []
@@ -393,7 +391,7 @@ branches:
393391
increment: Patch
394392
prevent-increment:
395393
when-current-commit-tagged: false
396-
regex: ^hotfix(es)?[/-](?<BranchName>.+)
394+
regex: ^hotfix(es)?[\/-](?<BranchName>.+)
397395
source-branches:
398396
- main
399397
is-source-branch-for: []
@@ -402,14 +400,13 @@ branches:
402400
pre-release-weight: 30000
403401
pull-request:
404402
mode: ContinuousDelivery
405-
label: PullRequest
403+
label: PullRequest{Number}
406404
increment: Inherit
407405
prevent-increment:
408406
of-merged-branch: true
409407
when-current-commit-tagged: false
410-
label-number-pattern: '[/-](?<number>\d+)'
411408
track-merge-message: true
412-
regex: ^(pull|pull\-requests|pr)[/-]
409+
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
413410
source-branches:
414411
- main
415412
- feature
@@ -690,7 +687,7 @@ branches:
690687
is-main-branch: false
691688
pre-release-weight: 0
692689
release:
693-
regex: ^releases?[/-]
690+
regex: ^releases?[\/-]
694691
mode: ContinuousDelivery
695692
label: beta
696693
increment: None
@@ -702,29 +699,28 @@ branches:
702699
is-main-branch: false
703700
pre-release-weight: 30000
704701
feature:
705-
regex: ^features?[/-]
702+
regex: ^features?[\/-]
706703
mode: ContinuousDelivery
707704
label: '{BranchName}'
708705
increment: Inherit
709706
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
710707
pre-release-weight: 30000
711708
pull-request:
712-
regex: ^(pull|pull\-requests|pr)[/-]
709+
regex: ^(pull-requests|pull|pr)[\/-]
713710
mode: ContinuousDelivery
714711
label: PullRequest
715712
increment: Inherit
716-
label-number-pattern: '[/-](?<number>\d+)[-/]'
717713
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
718714
pre-release-weight: 30000
719715
hotfix:
720-
regex: ^hotfix(es)?[/-]
716+
regex: ^hotfix(es)?[\/-]
721717
mode: ContinuousDelivery
722718
label: beta
723719
increment: Inherit
724720
source-branches: [ 'release', 'main', 'support', 'hotfix' ]
725721
pre-release-weight: 30000
726722
support:
727-
regex: ^support[/-]
723+
regex: ^support[\/-]
728724
mode: ContinuousDelivery
729725
label: ''
730726
increment: Patch
@@ -840,9 +836,9 @@ The pre-release label to use for this branch. Use the value `{BranchName}` as a
840836
insert the value of the named group `BranchName` from the [regular expression](#regex).
841837

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

845-
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+)[-/].+'`.
841+
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+)[-/].+'`.
846842

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

@@ -871,30 +867,6 @@ The increment of the merged branch will be ignored when this branch related prop
871867

872868
This branch related property controls the behvior whether to use the tagged (value set to true) or the incremented (value set to false) semantic version. Defaults to true.
873869

874-
### label-number-pattern
875-
876-
Pull requests require us to extract the pre-release number out of the branch
877-
name so `refs/pulls/534/merge` builds as `PullRequest.534`. This is a regex with
878-
a named capture group called `number`.
879-
880-
If the branch `mode` is set to `ContinuousDeployment`, then the extracted
881-
`number` is appended to the name of the pre-release label and the number portion
882-
is the number of commits since the last label. This enables consecutive commits to
883-
the pull request branch to generate unique full semantic version numbers when
884-
the branch is configured to use ContinuousDeployment mode.
885-
886-
**Example usage:**
887-
888-
```yaml
889-
branches:
890-
pull-request:
891-
mode: ContinuousDeployment
892-
label: PullRequest
893-
increment: Inherit
894-
track-merge-target: true
895-
label-number-pattern: '[/-](?<number>\d+)[-/]'
896-
```
897-
898870
### track-merge-target
899871

900872
Strategy which will look for tagged merge commits directly off the current

docs/input/docs/workflows/GitFlow/v1.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
assembly-versioning-scheme: MajorMinorPatch
1+
assembly-versioning-scheme: MajorMinorPatch
22
assembly-file-versioning-scheme: MajorMinorPatch
33
tag-prefix: '[vV]?'
44
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
@@ -57,7 +57,7 @@ branches:
5757
of-merged-branch: true
5858
when-current-commit-tagged: false
5959
track-merge-target: false
60-
regex: ^releases?[/-](?<BranchName>.+)
60+
regex: ^releases?[\/-](?<BranchName>.+)
6161
source-branches:
6262
- main
6363
- support
@@ -73,7 +73,7 @@ branches:
7373
prevent-increment:
7474
when-current-commit-tagged: false
7575
track-merge-message: true
76-
regex: ^features?[/-](?<BranchName>.+)
76+
regex: ^features?[\/-](?<BranchName>.+)
7777
source-branches:
7878
- develop
7979
- main
@@ -85,14 +85,13 @@ branches:
8585
pre-release-weight: 30000
8686
pull-request:
8787
mode: ContinuousDelivery
88-
label: PullRequest
88+
label: PullRequest{Number}
8989
increment: Inherit
9090
prevent-increment:
9191
of-merged-branch: true
9292
when-current-commit-tagged: false
93-
label-number-pattern: '[/-](?<number>\d+)'
9493
track-merge-message: true
95-
regex: ^(pull|pull\-requests|pr)[/-]
94+
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
9695
source-branches:
9796
- develop
9897
- main
@@ -108,7 +107,7 @@ branches:
108107
increment: Inherit
109108
prevent-increment:
110109
when-current-commit-tagged: false
111-
regex: ^hotfix(es)?[/-](?<BranchName>.+)
110+
regex: ^hotfix(es)?[\/-](?<BranchName>.+)
112111
source-branches:
113112
- main
114113
- support
@@ -122,7 +121,7 @@ branches:
122121
prevent-increment:
123122
of-merged-branch: true
124123
track-merge-target: false
125-
regex: ^support[/-](?<BranchName>.+)
124+
regex: ^support[\/-](?<BranchName>.+)
126125
source-branches:
127126
- main
128127
is-source-branch-for: []

docs/input/docs/workflows/GitHubFlow/v1.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
assembly-versioning-scheme: MajorMinorPatch
1+
assembly-versioning-scheme: MajorMinorPatch
22
assembly-file-versioning-scheme: MajorMinorPatch
33
tag-prefix: '[vV]?'
44
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
@@ -43,7 +43,7 @@ branches:
4343
when-current-commit-tagged: false
4444
track-merge-target: false
4545
track-merge-message: true
46-
regex: ^releases?[/-](?<BranchName>.+)
46+
regex: ^releases?[\/-](?<BranchName>.+)
4747
source-branches:
4848
- main
4949
is-source-branch-for: []
@@ -58,7 +58,7 @@ branches:
5858
prevent-increment:
5959
when-current-commit-tagged: false
6060
track-merge-message: true
61-
regex: ^features?[/-](?<BranchName>.+)
61+
regex: ^features?[\/-](?<BranchName>.+)
6262
source-branches:
6363
- main
6464
- release
@@ -67,14 +67,13 @@ branches:
6767
pre-release-weight: 30000
6868
pull-request:
6969
mode: ContinuousDelivery
70-
label: PullRequest
70+
label: PullRequest{Number}
7171
increment: Inherit
7272
prevent-increment:
7373
of-merged-branch: true
7474
when-current-commit-tagged: false
75-
label-number-pattern: '[/-](?<number>\d+)'
7675
track-merge-message: true
77-
regex: ^(pull|pull\-requests|pr)[/-]
76+
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
7877
source-branches:
7978
- main
8079
- release

docs/input/docs/workflows/TrunkBased/preview1.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
assembly-versioning-scheme: MajorMinorPatch
1+
assembly-versioning-scheme: MajorMinorPatch
22
assembly-file-versioning-scheme: MajorMinorPatch
33
tag-prefix: '[vV]?'
44
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
@@ -37,7 +37,7 @@ branches:
3737
prevent-increment:
3838
when-current-commit-tagged: false
3939
track-merge-message: true
40-
regex: ^features?[/-](?<BranchName>.+)
40+
regex: ^features?[\/-](?<BranchName>.+)
4141
source-branches:
4242
- main
4343
is-source-branch-for: []
@@ -49,7 +49,7 @@ branches:
4949
increment: Patch
5050
prevent-increment:
5151
when-current-commit-tagged: false
52-
regex: ^hotfix(es)?[/-](?<BranchName>.+)
52+
regex: ^hotfix(es)?[\/-](?<BranchName>.+)
5353
source-branches:
5454
- main
5555
is-source-branch-for: []
@@ -58,14 +58,13 @@ branches:
5858
pre-release-weight: 30000
5959
pull-request:
6060
mode: ContinuousDelivery
61-
label: PullRequest
61+
label: PullRequest{Number}
6262
increment: Inherit
6363
prevent-increment:
6464
of-merged-branch: true
6565
when-current-commit-tagged: false
66-
label-number-pattern: '[/-](?<number>\d+)'
6766
track-merge-message: true
68-
regex: ^(pull|pull\-requests|pr)[/-]
67+
regex: ^(pull-requests|pull|pr)[\/-](?<Number>\d*)
6968
source-branches:
7069
- main
7170
- feature

src/GitVersion.Configuration.Tests/Configuration/ConfigurationExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public void EnsureIsReleaseBranchWithReferenceNameWorksAsExpected(string branchN
4040
isReleaseBranch.ShouldBe(expectedIsReleaseBranch);
4141
}
4242

43-
[TestCase("feature/sc-1000/Description", "^features?[/-](?<BranchName>.+)", "{BranchName}", "sc-1000-Description")]
44-
[TestCase("feature/sc-1000/Description", "^features?[/-](?<StoryNo>sc-\\d+)[-/].+", "{StoryNo}", "sc-1000")]
43+
[TestCase("feature/sc-1000/Description", @"^features?[\/-](?<BranchName>.+)", "{BranchName}", "sc-1000-Description")]
44+
[TestCase("feature/sc-1000/Description", @"^features?[\/-](?<StoryNo>sc-\d+)[-\/].+", "{StoryNo}", "sc-1000")]
4545
public void EnsureGetBranchSpecificLabelWorksAsExpected(string branchName, string regularExpression, string label, string expectedLabel)
4646
{
4747
var configuration = GitFlowConfigurationBuilder.New

0 commit comments

Comments
 (0)