Skip to content
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
3 changes: 2 additions & 1 deletion BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* 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 `TrunkBased` version strategy should be used instead.
* The `TrunkBased` workflow doesn't support downgrading the increment for calculating the next version. This is the case if e.g. a bump messages has been defined which is lower than the branch increment.
* The branch related property `is-mainline` in the configuration system has been renamed to `is-main-branch`
* The versioning mode has been renamed to deployment mode and consists of following values:
* ManualDeployment (previously ContinuousDelivery)
Expand All @@ -53,7 +54,7 @@
* VersionInBranchName
* TrunkBased
* The initialization wizard has been removed.
* On the `develop`, `release` and `hotfix` branch the introduced branch related property `prevent-increment-when-current-commit-tagged` has been set to `false` to get the incremented instead of the tagged semantic version.
* On the `develop`, `release` and `hotfix` branch the introduced branch related property `prevent-increment.when-current-commit-tagged` has been set to `false` to get the incremented instead of the tagged semantic version.

## v5.0.0

Expand Down
69 changes: 46 additions & 23 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ branches:
develop:
label: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
prevent-increment-when-tagged: false
prevent-increment:
when-current-commit-tagged: false
track-merge-target: true
regex: ^dev(elop)?(ment)?$
source-branches: []
Expand All @@ -85,7 +85,8 @@ branches:
main:
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^master$|^main$
source-branches:
Expand All @@ -100,8 +101,9 @@ branches:
mode: ManualDeployment
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
prevent-increment-when-tagged: false
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
source-branches:
Expand All @@ -118,6 +120,7 @@ branches:
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
prevent-increment: {}
regex: ^features?[/-](?<BranchName>.+)
source-branches:
- develop
Expand All @@ -132,6 +135,7 @@ branches:
mode: ContinuousDelivery
label: PullRequest
increment: Inherit
prevent-increment: {}
label-number-pattern: '[/-](?<number>\d+)'
regex: ^(pull|pull\-requests|pr)[/-]
source-branches:
Expand All @@ -147,7 +151,8 @@ branches:
mode: ManualDeployment
label: beta
increment: Inherit
prevent-increment-when-tagged: false
prevent-increment:
when-current-commit-tagged: false
regex: ^hotfix(es)?[/-]
source-branches:
- release
Expand All @@ -160,7 +165,8 @@ branches:
support:
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^support[/-]
source-branches:
Expand All @@ -174,6 +180,7 @@ branches:
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
prevent-increment: {}
regex: (?<BranchName>.+)
source-branches:
- main
Expand All @@ -189,8 +196,10 @@ ignore:
mode: ContinuousDelivery
label: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
prevent-increment-when-tagged: true
prevent-increment:
of-merged-branch: false
when-branch-merged: false
when-current-commit-tagged: true
track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
Expand All @@ -200,6 +209,7 @@ is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false

```

The supported built-in configuration for the `GitHubFlow` workflow (`workflow: GitHubFlow/v1`) looks like:
Expand Down Expand Up @@ -228,7 +238,8 @@ branches:
main:
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^master$|^main$
source-branches:
Expand All @@ -242,8 +253,9 @@ branches:
mode: ManualDeployment
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
prevent-increment-when-tagged: false
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
source-branches:
Expand Down Expand Up @@ -293,8 +305,10 @@ ignore:
mode: ContinuousDelivery
label: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
prevent-increment-when-tagged: true
prevent-increment:
of-merged-branch: false
when-branch-merged: false
when-current-commit-tagged: true
track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
Expand Down Expand Up @@ -330,7 +344,8 @@ branches:
mode: ContinuousDeployment
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^master$|^main$
source-branches: []
Expand All @@ -341,14 +356,16 @@ branches:
feature:
increment: Minor
regex: ^features?[/-](?<BranchName>.+)
prevent-increment-when-tagged: false
prevent-increment:
when-current-commit-tagged: false
source-branches:
- main
pre-release-weight: 30000
hotfix:
increment: Patch
regex: ^hotfix(es)?[/-](?<BranchName>.+)
prevent-increment-when-tagged: false
prevent-increment:
when-current-commit-tagged: false
source-branches:
- main
pre-release-weight: 30000
Expand All @@ -375,8 +392,10 @@ ignore:
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
prevent-increment-when-tagged: true
prevent-increment:
of-merged-branch: false
when-branch-merged: false
when-current-commit-tagged: true
track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
Expand Down Expand Up @@ -467,9 +486,7 @@ increased, such as for commits after a tag: `Major`, `Minor`, `Patch`, `None`.

The special value `Inherit` means that GitVersion should find the parent branch
(i.e. the branch where the current branch was branched from), and use its values
for [increment](#increment),
[prevent-increment-of-merged-branch-version](#prevent-increment-of-merged-branch-version)
and [tracks-release-branches](#tracks-release-branches).
for [increment](#increment) or other branch related properties.

### tag-prefix

Expand Down Expand Up @@ -791,7 +808,9 @@ Another example: branch `features/sc-12345/some-description` would become a pre-

Same as for the [global configuration, explained above](#increment).

### prevent-increment-of-merged-branch-version
### prevent-increment-of-merged-branch

The increment of the branch merged to will be ignored, regardless of whether the merged branch has a version number or not, when this branch related property is set to true on the target branch.

When `release-2.0.0` is merged into main, we want main to build `2.0.0`. If
`release-2.0.0` is merged into develop we want it to build `2.1.0`, this option
Expand All @@ -802,6 +821,10 @@ In a GitFlow-based repository, setting this option can have implications on the
better version source proposed by the `MergeMessageBaseVersionStrategy`. For
more details and an in-depth analysis, please see [the discussion][2506].

### prevent-increment-when-branch-merged

The increment of the merged branch will be ignored when this branch related property is set to `true` on the source branch.

### prevent-increment-when-current-commit-tagged

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ branches:
develop:
label: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
prevent-increment-when-current-commit-tagged: false
prevent-increment:
when-current-commit-tagged: false
track-merge-target: true
regex: ^dev(elop)?(ment)?$
source-branches: []
Expand All @@ -34,7 +34,8 @@ branches:
main:
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^master$|^main$
source-branches:
Expand All @@ -49,8 +50,9 @@ branches:
mode: ManualDeployment
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
prevent-increment-when-current-commit-tagged: false
prevent-increment:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
source-branches:
Expand All @@ -67,6 +69,7 @@ branches:
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
prevent-increment: {}
regex: ^features?[/-](?<BranchName>.+)
source-branches:
- develop
Expand All @@ -81,6 +84,7 @@ branches:
mode: ContinuousDelivery
label: PullRequest
increment: Inherit
prevent-increment: {}
label-number-pattern: '[/-](?<number>\d+)'
regex: ^(pull|pull\-requests|pr)[/-]
source-branches:
Expand All @@ -96,7 +100,8 @@ branches:
mode: ManualDeployment
label: beta
increment: Inherit
prevent-increment-when-current-commit-tagged: false
prevent-increment:
when-current-commit-tagged: false
regex: ^hotfix(es)?[/-]
source-branches:
- release
Expand All @@ -109,7 +114,8 @@ branches:
support:
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^support[/-]
source-branches:
Expand All @@ -123,6 +129,7 @@ branches:
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
prevent-increment: {}
regex: (?<BranchName>.+)
source-branches:
- main
Expand All @@ -138,8 +145,10 @@ ignore:
mode: ContinuousDelivery
label: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
prevent-increment-when-current-commit-tagged: true
prevent-increment:
of-merged-branch: false
when-branch-merged: false
when-current-commit-tagged: true
track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
Expand Down
21 changes: 11 additions & 10 deletions src/GitVersion.Configuration/BranchConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ internal record BranchConfiguration : IBranchConfiguration
[JsonPropertyDescription("The increment strategy for this branch. Can be 'Inherit', 'Patch', 'Minor', 'Major', 'None'.")]
public IncrementStrategy Increment { get; internal set; }

[JsonPropertyName("prevent-increment-of-merged-branch-version")]
[JsonPropertyDescription("Prevent increment of merged branch version.")]
public bool? PreventIncrementOfMergedBranchVersion { get; internal set; }
[JsonIgnore]
IPreventIncrementConfiguration IBranchConfiguration.PreventIncrement => PreventIncrement;

[JsonPropertyName("prevent-increment-when-current-commit-tagged")]
[JsonPropertyDescription("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.")]
public bool? PreventIncrementWhenCurrentCommitTagged { get; internal set; }
[JsonPropertyName("prevent-increment")]
[JsonPropertyDescription("The prevent increment configuration section.")]
public PreventIncrementConfiguration PreventIncrement { get; internal set; } = new();

[JsonPropertyName("label-number-pattern")]
[JsonPropertyDescription($"The regular expression pattern to use to extract the number from the branch name. Defaults to '{ConfigurationConstants.DefaultLabelNumberPattern}'.")]
Expand Down Expand Up @@ -91,10 +90,12 @@ public virtual IBranchConfiguration Inherit(IBranchConfiguration configuration)
Increment = Increment == IncrementStrategy.Inherit ? configuration.Increment : Increment,
DeploymentMode = DeploymentMode ?? configuration.DeploymentMode,
Label = Label ?? configuration.Label,
PreventIncrementOfMergedBranchVersion = PreventIncrementOfMergedBranchVersion
?? configuration.PreventIncrementOfMergedBranchVersion,
PreventIncrementWhenCurrentCommitTagged = PreventIncrementWhenCurrentCommitTagged
?? configuration.PreventIncrementWhenCurrentCommitTagged,
PreventIncrement = new PreventIncrementConfiguration()
{
OfMergedBranch = PreventIncrement.OfMergedBranch ?? configuration.PreventIncrement.OfMergedBranch,
WhenBranchMerged = PreventIncrement.WhenBranchMerged ?? configuration.PreventIncrement.WhenBranchMerged,
WhenCurrentCommitTagged = PreventIncrement.WhenCurrentCommitTagged ?? configuration.PreventIncrement.WhenCurrentCommitTagged
},
LabelNumberPattern = LabelNumberPattern ?? configuration.LabelNumberPattern,
TrackMergeTarget = TrackMergeTarget ?? configuration.TrackMergeTarget,
TrackMergeMessage = TrackMergeMessage ?? configuration.TrackMergeMessage,
Expand Down
Loading