Skip to content

Commit 7fce4e6

Browse files
authored
Merge pull request #1433 from ruhullahshah/support_weighted_pre_release_number_per_branch
Provide a way to translate the PreReleaseLabel (alpha, beta etc) to a numeric value to avoid version collisions
2 parents 482dfce + db30469 commit 7fce4e6

File tree

29 files changed

+135
-9
lines changed

29 files changed

+135
-9
lines changed

docs/configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ branches:
206206
track-merge-target: false
207207
tracks-release-branches: false
208208
is-release-branch: true
209+
pre-release-weight: 1000
209210
feature:
210211
regex: ^features?[/-]
211212
mode: ContinuousDelivery
@@ -385,3 +386,6 @@ Indicates this branch config represents a release branch in GitFlow.
385386

386387
### is-mainline
387388
When using Mainline mode, this indicates that this branch is a mainline. By default support/ and master are mainlines.
389+
390+
### pre-release-weight
391+
Provides a way to translate the `PreReleaseLabel` ([variables](/more-info/variables)) to a numeric value in order to avoid version collisions across different branches. For example, a release branch created after "1.2.3-alpha.55" results in "1.2.3-beta.1" and thus e.g. "1.2.3-alpha.4" and "1.2.3-beta.4" would have the same file version: "1.2.3.4". One of the ways to use this value is to set `assembly-file-versioning-format: {Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber}`. If the `pre-release-weight` is set, it would be added to the `PreReleaseNumber` to get a final `AssemblySemFileVer`, otherwise a branch specific default for `pre-release-weight` will be used in the calculation. Related Issues [1145](https://github.com/GitTools/GitVersion/issues/1145), [1366](https://github.com/GitTools/GitVersion/issues/1366)

docs/more-info/variables.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ For the `release/3.0.0` branch of GitVersion it shows:
1111
"PreReleaseTagWithDash":"-beta.1",
1212
"PreReleaseLabel":"beta",
1313
"PreReleaseNumber":1,
14+
"WeightedPreReleaseNumber":1001,
1415
"BuildMetaData":1,
1516
"BuildMetaDataPadded": "0001",
1617
"FullBuildMetaData":"1.Branch.release/3.0.0.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
@@ -40,3 +41,6 @@ For the `release/3.0.0` branch of GitVersion it shows:
4041

4142
This is a common approach that gives you the ability to roll out hot fixes to your assembly without breaking existing applications that may be referencing it. You are still able to get the full version number if you need to by looking at its file version number.
4243

44+
#### What is WeightedPreReleaseNumber?
45+
46+
It is a summation of branch specific `pre-release-weight` and the `PreReleaseNumber`. It can be used to obtain a monotonically increasing version number across the branches.

src/GitVersionCore.Tests/Approved/JsonVersionBuilderTests.Json.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PreReleaseTagWithDash":"-unstable.4",
77
"PreReleaseLabel":"unstable",
88
"PreReleaseNumber":4,
9+
"WeightedPreReleaseNumber":4,
910
"BuildMetaData":5,
1011
"BuildMetaDataPadded":"0005",
1112
"FullBuildMetaData":"5.Branch.feature1.Sha.commitSha",

src/GitVersionCore.Tests/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PreReleaseTagWithDash":"-unstable.4",
77
"PreReleaseLabel":"unstable",
88
"PreReleaseNumber":4,
9+
"WeightedPreReleaseNumber":4,
910
"BuildMetaData":5,
1011
"BuildMetaDataPadded":"0005",
1112
"FullBuildMetaData":"5.Branch.develop.Sha.commitSha",

src/GitVersionCore.Tests/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreReleaseWithPadding.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PreReleaseTagWithDash":"-unstable.4",
77
"PreReleaseLabel":"unstable",
88
"PreReleaseNumber":4,
9+
"WeightedPreReleaseNumber":4,
910
"BuildMetaData":5,
1011
"BuildMetaDataPadded":"05",
1112
"FullBuildMetaData":"5.Branch.develop.Sha.commitSha",

src/GitVersionCore.Tests/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PreReleaseTagWithDash":"",
77
"PreReleaseLabel":"",
88
"PreReleaseNumber":"",
9+
"WeightedPreReleaseNumber":"",
910
"BuildMetaData":5,
1011
"BuildMetaDataPadded":"0005",
1112
"FullBuildMetaData":"5.Branch.develop.Sha.commitSha",

src/GitVersionCore.Tests/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PreReleaseTagWithDash":"-unstable.5",
77
"PreReleaseLabel":"unstable",
88
"PreReleaseNumber":5,
9+
"WeightedPreReleaseNumber":5,
910
"BuildMetaData":"",
1011
"BuildMetaDataPadded":"",
1112
"FullBuildMetaData":"Branch.develop.Sha.commitSha",

src/GitVersionCore.Tests/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PreReleaseTagWithDash":"-ci.5",
77
"PreReleaseLabel":"ci",
88
"PreReleaseNumber":5,
9+
"WeightedPreReleaseNumber":5,
910
"BuildMetaData":"",
1011
"BuildMetaDataPadded":"",
1112
"FullBuildMetaData":"Branch.develop.Sha.commitSha",

src/GitVersionCore.Tests/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"PreReleaseTagWithDash":"",
77
"PreReleaseLabel":"",
88
"PreReleaseNumber":"",
9+
"WeightedPreReleaseNumber":"",
910
"BuildMetaData":5,
1011
"BuildMetaDataPadded":"0005",
1112
"FullBuildMetaData":"5.Sha.commitSha",

src/GitVersionCore.Tests/Approved/WixFileTests.UpdateWixVersionFile.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@
2828
<?define SemVer="1.2.3"?>
2929
<?define Sha="commitSha"?>
3030
<?define ShortSha="commitShortSha"?>
31+
<?define WeightedPreReleaseNumber=""?>
3132
</Include>

src/GitVersionCore.Tests/Approved/cs/GitVersionInformationGeneratorTests.ShouldCreateFile.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static class GitVersionInformation
1818
public static string PreReleaseTagWithDash = "-unstable.4";
1919
public static string PreReleaseLabel = "unstable";
2020
public static string PreReleaseNumber = "4";
21+
public static string WeightedPreReleaseNumber = "4";
2122
public static string BuildMetaData = "5";
2223
public static string BuildMetaDataPadded = "0005";
2324
public static string FullBuildMetaData = "5.Branch.feature1.Sha.commitSha";

src/GitVersionCore.Tests/Approved/fs/GitVersionInformationGeneratorTests.ShouldCreateFile.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module GitVersionInformation
1818
let PreReleaseTagWithDash = "-unstable.4"
1919
let PreReleaseLabel = "unstable"
2020
let PreReleaseNumber = "4"
21+
let WeightedPreReleaseNumber = "4"
2122
let BuildMetaData = "5"
2223
let BuildMetaDataPadded = "0005"
2324
let FullBuildMetaData = "5.Branch.feature1.Sha.commitSha"

src/GitVersionCore.Tests/Approved/vb/GitVersionInformationGeneratorTests.ShouldCreateFile.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ NotInheritable Class GitVersionInformation
1919
Public Shared PreReleaseTagWithDash As String = "-unstable.4"
2020
Public Shared PreReleaseLabel As String = "unstable"
2121
Public Shared PreReleaseNumber As String = "4"
22+
Public Shared WeightedPreReleaseNumber As String = "4"
2223
Public Shared BuildMetaData As String = "5"
2324
Public Shared BuildMetaDataPadded As String = "0005"
2425
Public Shared FullBuildMetaData As String = "5.Branch.feature1.Sha.commitSha"

src/GitVersionCore.Tests/CommitDateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void CommitDateFormatTest(string format, string expectedOutcome)
2626
},
2727
new EffectiveConfiguration(
2828
AssemblyVersioningScheme.MajorMinorPatch, AssemblyFileVersioningScheme.MajorMinorPatch, "", "", "", VersioningMode.ContinuousDelivery, "", "", "", IncrementStrategy.Inherit,
29-
"", true, "", "", false, "", "", "", "", CommitMessageIncrementMode.Enabled, 4, 4, 4, Enumerable.Empty<IVersionFilter>(), false, true, format)
29+
"", true, "", "", false, "", "", "", "", CommitMessageIncrementMode.Enabled, 4, 4, 4, Enumerable.Empty<IVersionFilter>(), false, true, format, 0)
3030
);
3131

3232
Assert.That(formatValues.CommitDate, Is.EqualTo(expectedOutcome));

src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ branches:
2323
tracks-release-branches: true
2424
is-release-branch: false
2525
is-mainline: false
26+
pre-release-weight: 0
2627
master:
2728
mode: ContinuousDelivery
2829
tag: ''
@@ -36,6 +37,7 @@ branches:
3637
tracks-release-branches: false
3738
is-release-branch: false
3839
is-mainline: true
40+
pre-release-weight: 55000
3941
release:
4042
mode: ContinuousDelivery
4143
tag: beta
@@ -51,6 +53,7 @@ branches:
5153
tracks-release-branches: false
5254
is-release-branch: true
5355
is-mainline: false
56+
pre-release-weight: 30000
5457
feature:
5558
mode: ContinuousDelivery
5659
tag: useBranchName
@@ -68,6 +71,7 @@ branches:
6871
tracks-release-branches: false
6972
is-release-branch: false
7073
is-mainline: false
74+
pre-release-weight: 30000
7175
pull-request:
7276
mode: ContinuousDelivery
7377
tag: PullRequest
@@ -86,6 +90,7 @@ branches:
8690
tracks-release-branches: false
8791
is-release-branch: false
8892
is-mainline: false
93+
pre-release-weight: 30000
8994
hotfix:
9095
mode: ContinuousDelivery
9196
tag: beta
@@ -100,6 +105,7 @@ branches:
100105
tracks-release-branches: false
101106
is-release-branch: false
102107
is-mainline: false
108+
pre-release-weight: 30000
103109
support:
104110
mode: ContinuousDelivery
105111
tag: ''
@@ -112,6 +118,7 @@ branches:
112118
tracks-release-branches: false
113119
is-release-branch: false
114120
is-mainline: true
121+
pre-release-weight: 55000
115122
ignore:
116123
sha: []
117124
commit-date-format: yyyy-MM-dd

src/GitVersionCore.Tests/ExecuteCoreTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void CacheFileExistsOnDisk()
5050
PreReleaseTagWithDash: -test.19
5151
PreReleaseLabel: test
5252
PreReleaseNumber: 19
53+
WeightedPreReleaseNumber: 19
5354
BuildMetaData:
5455
BuildMetaDataPadded:
5556
FullBuildMetaData: Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
@@ -161,6 +162,7 @@ public void ConfigChangeInvalidatesCache()
161162
PreReleaseTagWithDash: -test.19
162163
PreReleaseLabel: test
163164
PreReleaseNumber: 19
165+
WeightedPreReleaseNumber: 19
164166
BuildMetaData:
165167
BuildMetaDataPadded:
166168
FullBuildMetaData: Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f
@@ -211,6 +213,7 @@ public void NoCacheBypassesCache()
211213
PreReleaseTagWithDash: -test.19
212214
PreReleaseLabel: test
213215
PreReleaseNumber: 19
216+
WeightedPreReleaseNumber: 19
214217
BuildMetaData:
215218
BuildMetaDataPadded:
216219
FullBuildMetaData: Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f

src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using GitTools.Testing;
1+
using GitTools.Testing;
22
using GitVersion;
33
using GitVersionCore.Tests;
44
using LibGit2Sharp;
@@ -551,6 +551,52 @@ public void FeatureFromReleaseBranch_ShouldNotResetCount()
551551
}
552552
}
553553

554+
[Test]
555+
public void AssemblySemFileVerShouldBeWeightedByPreReleaseWeight()
556+
{
557+
var config = new Config
558+
{
559+
AssemblyFileVersioningFormat = "{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber}",
560+
Branches =
561+
{
562+
{ "release", new BranchConfig
563+
{
564+
PreReleaseWeight = 1000
565+
}
566+
}
567+
}
568+
};
569+
using (var fixture = new EmptyRepositoryFixture())
570+
{
571+
fixture.Repository.MakeATaggedCommit("1.0.3");
572+
fixture.Repository.MakeCommits(5);
573+
fixture.Repository.CreateBranch("release-2.0.0");
574+
fixture.Checkout("release-2.0.0");
575+
ConfigurationProvider.ApplyDefaultsTo(config);
576+
var variables = fixture.GetVersion(config);
577+
Assert.AreEqual(variables.AssemblySemFileVer, "2.0.0.1001");
578+
}
579+
}
580+
581+
[Test]
582+
public void AssemblySemFileVerShouldBeWeightedByDefaultPreReleaseWeight()
583+
{
584+
var config = new Config
585+
{
586+
AssemblyFileVersioningFormat = "{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber}",
587+
};
588+
using (var fixture = new EmptyRepositoryFixture())
589+
{
590+
fixture.Repository.MakeATaggedCommit("1.0.3");
591+
fixture.Repository.MakeCommits(5);
592+
fixture.Repository.CreateBranch("release-2.0.0");
593+
fixture.Checkout("release-2.0.0");
594+
ConfigurationProvider.ApplyDefaultsTo(config);
595+
var variables = fixture.GetVersion(config);
596+
Assert.AreEqual(variables.AssemblySemFileVer, "2.0.0.30001");
597+
}
598+
}
599+
554600
/// <summary>
555601
/// Create a feature branch from a release branch, and merge back, then delete it
556602
/// </summary>
@@ -623,4 +669,4 @@ public void FeatureOnRelease_FeatureBranchNotDeleted()
623669
fixture.AssertFullSemver(config, "4.5.0-beta.2");
624670
}
625671
}
626-
}
672+
}

src/GitVersionCore.Tests/TestEffectiveConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public TestEffectiveConfiguration(
4040
majorMessage, minorMessage, patchMessage, noBumpMessage,
4141
commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding,
4242
versionFilters ?? Enumerable.Empty<IVersionFilter>(),
43-
tracksReleaseBranches, isRelease, commitDateFormat)
43+
tracksReleaseBranches, isRelease, commitDateFormat, 0)
4444
{
4545
}
4646
}

src/GitVersionCore.Tests/TestableVersionVariables.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,22 @@
44

55
class TestableVersionVariables : VersionVariables
66
{
7-
public TestableVersionVariables(string major = "", string minor = "", string patch = "", string buildMetaData = "", string buildMetaDataPadded = "", string fullBuildMetaData = "", string branchName = "", string sha = "", string shortSha = "", string majorMinorPatch = "", string semVer = "", string legacySemVer = "", string legacySemVerPadded = "", string fullSemVer = "", string assemblySemVer = "", string assemblySemFileVer = "", string preReleaseTag = "", string preReleaseTagWithDash = "", string preReleaseLabel = "", string preReleaseNumber = "", string informationalVersion = "", string commitDate = "", string nugetVersion = "", string nugetVersionV2 = "", string nugetPreReleaseTag = "", string nugetPreReleaseTagV2 = "", string commitsSinceVersionSource = "", string commitsSinceVersionSourcePadded = "") : base(major, minor, patch, buildMetaData, buildMetaDataPadded, fullBuildMetaData, branchName, sha, shortSha, majorMinorPatch, semVer, legacySemVer, legacySemVerPadded, fullSemVer, assemblySemVer, assemblySemFileVer, preReleaseTag, preReleaseTagWithDash, preReleaseLabel, preReleaseNumber, informationalVersion, commitDate, nugetVersion, nugetVersionV2, nugetPreReleaseTag, nugetPreReleaseTagV2, commitsSinceVersionSource, commitsSinceVersionSourcePadded)
7+
public TestableVersionVariables(
8+
string major = "", string minor = "", string patch = "", string buildMetaData = "",
9+
string buildMetaDataPadded = "", string fullBuildMetaData = "", string branchName = "",
10+
string sha = "", string shortSha = "", string majorMinorPatch = "", string semVer = "",
11+
string legacySemVer = "", string legacySemVerPadded = "", string fullSemVer = "",
12+
string assemblySemVer = "", string assemblySemFileVer = "", string preReleaseTag = "",
13+
string preReleaseTagWithDash = "", string preReleaseLabel = "", string preReleaseNumber = "",
14+
string weightedPreReleaseNumber = "", string informationalVersion = "", string commitDate = "",
15+
string nugetVersion = "", string nugetVersionV2 = "", string nugetPreReleaseTag = "",
16+
string nugetPreReleaseTagV2 = "", string commitsSinceVersionSource = "",
17+
string commitsSinceVersionSourcePadded = "") : base(
18+
major, minor, patch, buildMetaData, buildMetaDataPadded, fullBuildMetaData, branchName,
19+
sha, shortSha, majorMinorPatch, semVer, legacySemVer, legacySemVerPadded, fullSemVer,
20+
assemblySemVer, assemblySemFileVer, preReleaseTag, weightedPreReleaseNumber, preReleaseTagWithDash,
21+
preReleaseLabel, preReleaseNumber, informationalVersion, commitDate, nugetVersion, nugetVersionV2,
22+
nugetPreReleaseTag, nugetPreReleaseTagV2, commitsSinceVersionSource, commitsSinceVersionSourcePadded)
823
{
924
}
1025
}

src/GitVersionCore/Configuration/BranchConfig.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public BranchConfig(BranchConfig branchConfiguration)
2828
Name = branchConfiguration.Name;
2929
SourceBranches = branchConfiguration.SourceBranches;
3030
IsSourceBranchFor = branchConfiguration.IsSourceBranchFor;
31+
PreReleaseWeight = branchConfiguration.PreReleaseWeight;
3132
}
3233

3334
[YamlMember(Alias = "mode")]
@@ -72,6 +73,9 @@ public BranchConfig(BranchConfig branchConfiguration)
7273
[YamlMember(Alias = "is-mainline")]
7374
public bool? IsMainline { get; set; }
7475

76+
[YamlMember(Alias = "pre-release-weight")]
77+
public int? PreReleaseWeight { get; set; }
78+
7579
/// <summary>
7680
/// The name given to this configuration in the config file.
7781
/// </summary>

src/GitVersionCore/Configuration/ConfigurationProvider.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ public class ConfigurationProvider
2828
public const string HotfixBranchKey = "hotfix";
2929
public const string SupportBranchKey = "support";
3030
public const string DevelopBranchKey = "develop";
31+
public static Dictionary<string, int> DefaultPreReleaseWeight =
32+
new Dictionary<string, int>
33+
{
34+
{ DevelopBranchRegex, 0 },
35+
{ HotfixBranchRegex, 30000 },
36+
{ ReleaseBranchRegex, 30000 },
37+
{ FeatureBranchRegex, 30000 },
38+
{ PullRequestRegex, 30000 },
39+
{ SupportBranchRegex, 55000 },
40+
{ MasterBranchRegex, 55000 }
41+
};
3142

3243
private const IncrementStrategy DefaultIncrementStrategy = IncrementStrategy.Inherit;
3344

@@ -231,6 +242,9 @@ public static void ApplyBranchDefaults(Config config,
231242
branchConfig.TracksReleaseBranches = branchConfig.TracksReleaseBranches ?? tracksReleaseBranches;
232243
branchConfig.IsReleaseBranch = branchConfig.IsReleaseBranch ?? isReleaseBranch;
233244
branchConfig.IsMainline = branchConfig.IsMainline ?? isMainline;
245+
int defaultPreReleaseNumber = 0;
246+
DefaultPreReleaseWeight.TryGetValue(branchRegex, out defaultPreReleaseNumber);
247+
branchConfig.PreReleaseWeight = branchConfig.PreReleaseWeight ?? defaultPreReleaseNumber;
234248
}
235249

236250
static Config ReadConfig(string workingDirectory, IFileSystem fileSystem)

src/GitVersionCore/EffectiveConfiguration.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public EffectiveConfiguration(
3232
IEnumerable<IVersionFilter> versionFilters,
3333
bool tracksReleaseBranches,
3434
bool isCurrentBranchRelease,
35-
string commitDateFormat)
35+
string commitDateFormat,
36+
int preReleaseWeight)
3637
{
3738
AssemblyVersioningScheme = assemblyVersioningScheme;
3839
AssemblyFileVersioningScheme = assemblyFileVersioningScheme;
@@ -61,6 +62,7 @@ public EffectiveConfiguration(
6162
TracksReleaseBranches = tracksReleaseBranches;
6263
IsCurrentBranchRelease = isCurrentBranchRelease;
6364
CommitDateFormat = commitDateFormat;
65+
PreReleaseWeight = preReleaseWeight;
6466
}
6567

6668
public bool TracksReleaseBranches { get; private set; }
@@ -115,5 +117,7 @@ public EffectiveConfiguration(
115117
public IEnumerable<IVersionFilter> VersionFilters { get; private set; }
116118

117119
public string CommitDateFormat { get; private set; }
120+
121+
public int PreReleaseWeight { get; private set; }
118122
}
119123
}

src/GitVersionCore/GitVersionContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ void CalculateEffectiveConfiguration()
117117
var incrementStrategy = currentBranchConfig.Increment.Value;
118118
var preventIncrementForMergedBranchVersion = currentBranchConfig.PreventIncrementOfMergedBranchVersion.Value;
119119
var trackMergeTarget = currentBranchConfig.TrackMergeTarget.Value;
120+
var preReleaseWeight = currentBranchConfig.PreReleaseWeight ?? 0;
120121

121122
var nextVersion = FullConfiguration.NextVersion;
122123
var assemblyVersioningScheme = FullConfiguration.AssemblyVersioningScheme.Value;
@@ -148,7 +149,8 @@ void CalculateEffectiveConfiguration()
148149
FullConfiguration.Ignore.ToFilters(),
149150
currentBranchConfig.TracksReleaseBranches.Value,
150151
currentBranchConfig.IsReleaseBranch.Value,
151-
commitDateFormat);
152+
commitDateFormat,
153+
preReleaseWeight);
152154
}
153155

154156
private static Branch GetTargetBranch(IRepository repository, string targetBranch)

0 commit comments

Comments
 (0)