Skip to content

Commit 3a21fc0

Browse files
committed
Use D3 number format when bumping suffix version
When bumping `-alpha01`, get `-alpha002` instead of `-alpha2`. This provides lexical sorting of up to 999 versions of a pre-release version.
1 parent acae44e commit 3a21fc0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Build/set-version.psm1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,16 @@ function BumpSuffix([string] $oldSuffix) {
116116

117117
# A suffix is a dash '-', then a sequcence of word characters followed by an optional number
118118
# Example:
119-
# -alpha => -alpha2
120-
# -alpha1 => -alpha2
119+
# -alpha => -alpha002
120+
# -alpha1 => -alpha002
121121
$match = [regex]::Match($oldSuffix, '^-([a-zA-Z]+)(\d+)?$');
122122
$oldSuffix = $match.Groups[1].Value
123123
$numberGroup = $match.Groups[2]
124124

125125
$number = if ($numberGroup.Success) { 1+$match.Groups[2].Value } else { 2 }
126-
return [string]::Format("-{0}{1}", $oldSuffix, $number)
126+
127+
# Use 3 digits for the number "-alpha003", for 999 releases lexically sorted.
128+
return [string]::Format("-{0}{1:D3}", $oldSuffix, $number)
127129
}
128130

129131
# Returns object with properties: Version, Suffix

0 commit comments

Comments
 (0)