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>

0 commit comments

Comments
 (0)