Skip to content

Commit

Permalink
Same version computed on different branches
Browse files Browse the repository at this point in the history
  • Loading branch information
HHobeck committed Feb 6, 2024
1 parent 5a1a920 commit 799b9e2
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 25 deletions.
38 changes: 31 additions & 7 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The global configuration looks like this:
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
tag-prefix: '[vV]?'
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
Expand All @@ -52,16 +53,22 @@ commit-date-format: yyyy-MM-dd
merge-message-formats: {}
update-build-number: true
semantic-version-format: Strict
strategies: [ConfigNext, MergeMessage, TaggedCommit, TrackReleaseBranches, VersionInBranchName]
strategies:
- ConfiguredNextVersion
- MergeMessage
- TaggedCommit
- TrackReleaseBranches
- VersionInBranchName
branches:
develop:
mode: ContinuousDeployment
take-incremented-version: TakeAlwaysIncrementedVersion
label: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
regex: ^dev(elop)?(ment)?$
source-branches: []
is-source-branch-for: []
tracks-release-branches: true
is-release-branch: false
is-main-branch: false
Expand All @@ -75,11 +82,14 @@ branches:
source-branches:
- develop
- release
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
release:
mode: ManualDeployment
take-incremented-version: TakeAlwaysIncrementedVersion
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
Expand All @@ -90,12 +100,13 @@ branches:
- main
- support
- release
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: true
is-main-branch: false
pre-release-weight: 30000
feature:
mode: ContinuousDelivery
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
regex: ^features?[/-](?<BranchName>.+)
Expand All @@ -106,6 +117,7 @@ branches:
- feature
- support
- hotfix
is-source-branch-for: []
pre-release-weight: 30000
pull-request:
mode: ContinuousDelivery
Expand All @@ -120,9 +132,10 @@ branches:
- feature
- support
- hotfix
is-source-branch-for: []
pre-release-weight: 30000
hotfix:
mode: ContinuousDelivery
mode: ManualDeployment
label: beta
increment: Inherit
regex: ^hotfix(es)?[/-]
Expand All @@ -131,6 +144,8 @@ branches:
- main
- support
- hotfix
is-source-branch-for: []
is-release-branch: true
pre-release-weight: 30000
support:
label: ''
Expand All @@ -140,15 +155,16 @@ branches:
regex: ^support[/-]
source-branches:
- main
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
unknown:
mode: ContinuousDelivery
mode: ManualDeployment
label: '{BranchName}'
increment: Inherit
regex: (?<BranchName>.*)
regex: (?<BranchName>.+)
source-branches:
- main
- develop
Expand All @@ -157,16 +173,20 @@ branches:
- pull-request
- hotfix
- support
is-source-branch-for: []
ignore:
sha: []
mode: ContinuousDelivery
take-incremented-version: TakeTaggedOtherwiseIncrementedVersion
label: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
regex: ''
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false
Expand Down Expand Up @@ -244,7 +264,11 @@ The default value is `{InformationalVersion}`.
### mode

Sets the `mode` of how GitVersion should create a new version. Read more at
[versioning modes][modes].
[deployment modes][modes].

### take-incremented-version

This branch related property can be used to control the behavior weither to take the incremented or the tagged version.

### increment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ strategies:
- VersionInBranchName
branches:
develop:
take-incremented-version: TakeAlwaysIncrementedVersion
label: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
Expand Down Expand Up @@ -46,6 +47,7 @@ branches:
pre-release-weight: 55000
release:
mode: ManualDeployment
take-incremented-version: TakeAlwaysIncrementedVersion
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
Expand Down Expand Up @@ -133,6 +135,7 @@ branches:
ignore:
sha: []
mode: ContinuousDelivery
take-incremented-version: TakeTaggedOtherwiseIncrementedVersion
label: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
Expand Down
5 changes: 5 additions & 0 deletions src/GitVersion.Configuration/BranchConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ internal record BranchConfiguration : IBranchConfiguration
[JsonPropertyDescription("The deployment mode for this branch. Can be 'ManualDeployment', 'ContinuousDelivery', 'ContinuousDeployment'.")]
public DeploymentMode? DeploymentMode { get; internal set; }

[JsonPropertyName("take-incremented-version")]
[JsonPropertyDescription("Option to control which version should be taken for this branch. Can be 'TakeAlwaysBaseVersion', 'TakeTaggedOtherwiseIncrementedVersion', 'TakeAlwaysIncrementedVersion'.")]
public TakeIncrementedVersion? TakeIncrementedVersion { get; internal set; }

[JsonPropertyName("label")]
[JsonPropertyDescription("The label to use for this branch. Use the value {BranchName} or similar as a placeholder to insert a named capture group from RegularExpression (fx. the branch name).")]
public string? Label { get; internal set; }
Expand Down Expand Up @@ -86,6 +90,7 @@ public virtual IBranchConfiguration Inherit(IBranchConfiguration configuration)
{
Increment = Increment == IncrementStrategy.Inherit ? configuration.Increment : Increment,
DeploymentMode = DeploymentMode ?? configuration.DeploymentMode,
TakeIncrementedVersion = TakeIncrementedVersion ?? configuration.TakeIncrementedVersion,
Label = Label ?? configuration.Label,
PreventIncrementOfMergedBranchVersion = PreventIncrementOfMergedBranchVersion
?? configuration.PreventIncrementOfMergedBranchVersion,
Expand Down
9 changes: 9 additions & 0 deletions src/GitVersion.Configuration/BranchConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal class BranchConfigurationBuilder
public static BranchConfigurationBuilder New => new();

private DeploymentMode? deploymentMode;
private TakeIncrementedVersion? takeIncrementedVersion;
private string? label;
private IncrementStrategy increment;
private bool? preventIncrementOfMergedBranchVersion;
Expand All @@ -32,6 +33,12 @@ public virtual BranchConfigurationBuilder WithDeploymentMode(DeploymentMode? val
return this;
}

public virtual BranchConfigurationBuilder WithTakeIncrementedVersion(TakeIncrementedVersion? value)
{
this.takeIncrementedVersion = value;
return this;
}

public virtual BranchConfigurationBuilder WithLabel(string? value)
{
this.label = value;
Expand Down Expand Up @@ -131,6 +138,7 @@ public virtual BranchConfigurationBuilder WithPreReleaseWeight(int? value)
public virtual BranchConfigurationBuilder WithConfiguration(IBranchConfiguration value)
{
WithDeploymentMode(value.DeploymentMode);
WithTakeIncrementedVersion(value.TakeIncrementedVersion);
WithLabel(value.Label);
WithIncrement(value.Increment);
WithPreventIncrementOfMergedBranchVersion(value.PreventIncrementOfMergedBranchVersion);
Expand All @@ -151,6 +159,7 @@ public virtual BranchConfigurationBuilder WithConfiguration(IBranchConfiguration
public IBranchConfiguration Build() => new BranchConfiguration
{
DeploymentMode = deploymentMode,
TakeIncrementedVersion = takeIncrementedVersion,
Label = label,
Increment = increment,
RegularExpression = regularExpression,
Expand Down
9 changes: 9 additions & 0 deletions src/GitVersion.Configuration/ConfigurationBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal abstract class ConfigurationBuilderBase<TConfigurationBuilder> : IConfi
private readonly List<IReadOnlyDictionary<object, object?>> overrides = new();
private readonly Dictionary<string, BranchConfigurationBuilder> branchConfigurationBuilders = new();
private DeploymentMode? versioningMode;
private TakeIncrementedVersion? takeIncrementedVersion;
private string? label;
private IncrementStrategy increment = IncrementStrategy.Inherit;
private bool? preventIncrementOfMergedBranchVersion;
Expand Down Expand Up @@ -237,6 +238,12 @@ public virtual TConfigurationBuilder WithDeploymentMode(DeploymentMode? value)
return (TConfigurationBuilder)this;
}

public virtual TConfigurationBuilder WithTakeIncrementedVersion(TakeIncrementedVersion? value)
{
this.takeIncrementedVersion = value;
return (TConfigurationBuilder)this;
}

public virtual TConfigurationBuilder WithLabel(string? value)
{
this.label = value;
Expand Down Expand Up @@ -335,6 +342,7 @@ public virtual TConfigurationBuilder WithConfiguration(IGitVersionConfiguration
WithBranch(name).WithConfiguration(branchConfiguration);
}
WithDeploymentMode(value.DeploymentMode);
WithTakeIncrementedVersion(value.TakeIncrementedVersion);
WithLabel(value.Label);
WithIncrement(value.Increment);
WithPreventIncrementOfMergedBranchVersion(value.PreventIncrementOfMergedBranchVersion);
Expand Down Expand Up @@ -393,6 +401,7 @@ public virtual IGitVersionConfiguration Build()
Branches = branches,
MergeMessageFormats = this.mergeMessageFormats,
DeploymentMode = this.versioningMode,
TakeIncrementedVersion = this.takeIncrementedVersion,
Label = this.label,
Increment = this.increment,
RegularExpression = this.regularExpression,
Expand Down
3 changes: 3 additions & 0 deletions src/GitVersion.Configuration/GitFlowConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private GitFlowConfigurationBuilder()
TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight,
UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber,
DeploymentMode = DeploymentMode.ContinuousDelivery,
TakeIncrementedVersion = TakeIncrementedVersion.TakeTaggedOtherwiseIncrementedVersion,
RegularExpression = string.Empty,
Label = ConfigurationConstants.BranchNamePlaceholder,
Increment = IncrementStrategy.Inherit,
Expand All @@ -39,6 +40,7 @@ private GitFlowConfigurationBuilder()
WithBranch(DevelopBranch.Name).WithConfiguration(new BranchConfiguration
{
Increment = IncrementStrategy.Minor,
TakeIncrementedVersion = TakeIncrementedVersion.TakeAlwaysIncrementedVersion,
RegularExpression = DevelopBranch.RegexPattern,
SourceBranches = [],
Label = "alpha",
Expand Down Expand Up @@ -71,6 +73,7 @@ private GitFlowConfigurationBuilder()
WithBranch(ReleaseBranch.Name).WithConfiguration(new BranchConfiguration
{
Increment = IncrementStrategy.None,
TakeIncrementedVersion = TakeIncrementedVersion.TakeAlwaysIncrementedVersion,
DeploymentMode = DeploymentMode.ManualDeployment,
RegularExpression = ReleaseBranch.RegexPattern,
SourceBranches =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private GitHubFlowConfigurationBuilder()
RegularExpression = string.Empty,
Label = ConfigurationConstants.BranchNamePlaceholder,
Increment = IncrementStrategy.Inherit,
TakeIncrementedVersion = TakeIncrementedVersion.TakeTaggedOtherwiseIncrementedVersion,
CommitMessageIncrementing = CommitMessageIncrementMode.Enabled,
PreventIncrementOfMergedBranchVersion = false,
TrackMergeTarget = false,
Expand All @@ -53,6 +54,7 @@ private GitHubFlowConfigurationBuilder()
WithBranch(ReleaseBranch.Name).WithConfiguration(new BranchConfiguration
{
Increment = IncrementStrategy.None,
TakeIncrementedVersion = TakeIncrementedVersion.TakeAlwaysIncrementedVersion,
RegularExpression = ReleaseBranch.RegexPattern,
DeploymentMode = DeploymentMode.ManualDeployment,
SourceBranches =
Expand Down
13 changes: 13 additions & 0 deletions src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ strategies:
- VersionInBranchName
branches:
develop:
take-incremented-version: TakeAlwaysIncrementedVersion
label: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
regex: ^dev(elop)?(ment)?$
source-branches: []
is-source-branch-for: []
tracks-release-branches: true
is-release-branch: false
is-main-branch: false
Expand All @@ -38,12 +40,14 @@ branches:
source-branches:
- develop
- release
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
release:
mode: ManualDeployment
take-incremented-version: TakeAlwaysIncrementedVersion
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
Expand All @@ -54,6 +58,7 @@ branches:
- main
- support
- release
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: true
is-main-branch: false
Expand All @@ -70,6 +75,7 @@ branches:
- feature
- support
- hotfix
is-source-branch-for: []
pre-release-weight: 30000
pull-request:
mode: ContinuousDelivery
Expand All @@ -84,6 +90,7 @@ branches:
- feature
- support
- hotfix
is-source-branch-for: []
pre-release-weight: 30000
hotfix:
mode: ManualDeployment
Expand All @@ -95,6 +102,7 @@ branches:
- main
- support
- hotfix
is-source-branch-for: []
is-release-branch: true
pre-release-weight: 30000
support:
Expand All @@ -105,6 +113,7 @@ branches:
regex: ^support[/-]
source-branches:
- main
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
Expand All @@ -122,16 +131,20 @@ branches:
- pull-request
- hotfix
- support
is-source-branch-for: []
ignore:
sha: []
mode: ContinuousDelivery
take-incremented-version: TakeTaggedOtherwiseIncrementedVersion
label: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
regex: ''
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false
Loading

0 comments on commit 799b9e2

Please sign in to comment.