Skip to content

Commit d713fd5

Browse files
committed
Set a default value of 60000 for the TagPreReleaseWeight
1 parent ae8d3ba commit d713fd5

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

docs/input/docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ set to `4`, which will pad the `CommitsSinceVersionSource` value of `1` to
201201

202202
### tag-pre-release-weight
203203

204-
The pre-release weight in case of tagged commits. If the value is not set in the configuration, a default weight of 0 is used instead. If the `WeightedPreReleaseNumber` [variable](./more-info/variables) is 0 and this parameter is set, its value is used. This helps if your branching model is GitFlow and the last release build, which is often tagged, can utilise this parameter to produce a monotonically increasing build number.
204+
The pre-release weight in case of tagged commits. If the value is not set in the configuration, a default weight of 60000 is used instead. If the `WeightedPreReleaseNumber` [variable](./more-info/variables) is 0 and this parameter is set, its value is used. This helps if your branching model is GitFlow and the last release build, which is often tagged, can utilise this parameter to produce a monotonically increasing build number.
205205

206206
### commit-message-incrementing
207207

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ no-bump-message: '\+semver:\s?(none|skip)'
1010
legacy-semver-padding: 4
1111
build-metadata-padding: 4
1212
commits-since-version-source-padding: 4
13-
tag-pre-release-weight: 0
13+
tag-pre-release-weight: 60000
1414
commit-message-incrementing: Enabled
1515
branches:
1616
develop:

src/GitVersionCore.Tests/IntegrationTests/VersionInTagScenarios.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace GitVersionCore.Tests.IntegrationTests
1111
class VersionInTagScenarios
1212
{
1313
[Test]
14-
public void TagPreReleaseWeightIsNotConfigured_HeadIsATaggedCommit_WeightedPreReleaseNumberShouldBeZero()
14+
public void TagPreReleaseWeightIsNotConfigured_HeadIsATaggedCommit_WeightedPreReleaseNumberShouldBeTheDefaultValue()
1515
{
1616
// Arrange
1717
var config = new Config()
@@ -26,7 +26,7 @@ public void TagPreReleaseWeightIsNotConfigured_HeadIsATaggedCommit_WeightedPreRe
2626
var version = fixture.GetVersion(config);
2727

2828
// Assert
29-
version.AssemblySemFileVer.ShouldBe("1.1.0.0");
29+
version.AssemblySemFileVer.ShouldBe("1.1.0.60000");
3030
}
3131

3232
[Test]
@@ -36,7 +36,7 @@ public void TagPreReleaseWeightIsConfigured_HeadIsATaggedCommit_WeightedPreRelea
3636
var config = new Config()
3737
{
3838
AssemblyFileVersioningFormat = "{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber}",
39-
TagPreReleaseWeight = 60000
39+
TagPreReleaseWeight = 65535
4040
};
4141
config.ApplyDefaults();
4242

@@ -46,7 +46,7 @@ public void TagPreReleaseWeightIsConfigured_HeadIsATaggedCommit_WeightedPreRelea
4646
var version = fixture.GetVersion(config);
4747

4848
// Assert
49-
version.AssemblySemFileVer.ShouldBe("1.1.0.60000");
49+
version.AssemblySemFileVer.ShouldBe("1.1.0.65535");
5050
}
5151

5252
[Test]
@@ -56,7 +56,7 @@ public void TagPreReleaseWeightIsConfigured_GitFlowReleaseIsFinished_WeightedPre
5656
var config = new Config()
5757
{
5858
AssemblyFileVersioningFormat = "{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber}",
59-
TagPreReleaseWeight = 60000,
59+
TagPreReleaseWeight = 65535,
6060
VersioningMode = VersioningMode.ContinuousDeployment
6161
};
6262
config.ApplyDefaults();
@@ -74,11 +74,11 @@ public void TagPreReleaseWeightIsConfigured_GitFlowReleaseIsFinished_WeightedPre
7474
var version = fixture.GetVersion(config);
7575

7676
// Assert
77-
version.AssemblySemFileVer.ShouldBe("1.1.0.60000");
77+
version.AssemblySemFileVer.ShouldBe("1.1.0.65535");
7878
}
7979

8080
[Test]
81-
public void TagPreReleaseWeightIsNotConfigured_GitFlowReleaseIsFinished_WeightedPreReleaseNumberShouldBeZero()
81+
public void TagPreReleaseWeightIsNotConfigured_GitFlowReleaseIsFinished_WeightedPreReleaseNumberShouldBeTheDefaultValue()
8282
{
8383
// Arrange
8484
var config = new Config()
@@ -101,7 +101,7 @@ public void TagPreReleaseWeightIsNotConfigured_GitFlowReleaseIsFinished_Weighted
101101
var version = fixture.GetVersion(config);
102102

103103
// Assert
104-
version.AssemblySemFileVer.ShouldBe("1.1.0.0");
104+
version.AssemblySemFileVer.ShouldBe("1.1.0.60000");
105105
}
106106
}
107107
}

src/GitVersionCore/Configuration/ConfigExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void Reset(this Config config)
3737
config.CommitsSinceVersionSourcePadding ??= 4;
3838
config.CommitDateFormat ??= "yyyy-MM-dd";
3939
config.UpdateBuildNumber ??= true;
40-
config.TagPreReleaseWeight ??= 0;
40+
config.TagPreReleaseWeight ??= DefaultTagPreReleaseWeight;
4141

4242
var configBranches = config.Branches.ToList();
4343

@@ -129,6 +129,7 @@ public static void Reset(this Config config)
129129
{ Config.MasterBranchRegex, 55000 }
130130
};
131131
private const IncrementStrategy DefaultIncrementStrategy = IncrementStrategy.Inherit;
132+
private const int DefaultTagPreReleaseWeight = 60000;
132133

133134
public static void ApplyBranchDefaults(this Config config,
134135
BranchConfig branchConfig,
@@ -267,7 +268,7 @@ public static EffectiveConfiguration CalculateEffectiveConfiguration(this Config
267268
var noBumpMessage = configuration.NoBumpMessage;
268269
var commitDateFormat = configuration.CommitDateFormat;
269270
var updateBuildNumber = configuration.UpdateBuildNumber ?? true;
270-
var tagPreReleaseWeight = configuration.TagPreReleaseWeight;
271+
var tagPreReleaseWeight = configuration.TagPreReleaseWeight ?? DefaultTagPreReleaseWeight;
271272

272273
var commitMessageVersionBump = currentBranchConfig.CommitMessageIncrementing ?? configuration.CommitMessageIncrementing.Value;
273274
return new EffectiveConfiguration(
@@ -288,7 +289,7 @@ public static EffectiveConfiguration CalculateEffectiveConfiguration(this Config
288289
commitDateFormat,
289290
updateBuildNumber,
290291
preReleaseWeight,
291-
tagPreReleaseWeight.HasValue ? tagPreReleaseWeight.Value : 0);
292+
tagPreReleaseWeight);
292293
}
293294

294295
public static string GetBranchSpecificTag(this EffectiveConfiguration configuration, ILog log, string branchFriendlyName, string branchNameOverride)

0 commit comments

Comments
 (0)