Skip to content

Commit 82ac432

Browse files
authored
Fixes #20 - Updates support to show Number and fix even if 0 (#21)
* CSemVer-CI doesn't spell this (or much else) out explicitly. Instead it relies on examples assuming you see all the aspects of such a thing. * For a CSemVer-CI, as long as a Pre-release name exists, then the number and fix are always included even if 0. * Corrected spelling of parameter for PrereleaseVersion. * Updated tests to account for inclusion of number and fix in CI prerelease builds * Updated to latest task that includes fix for the same underlying issue so this package is versioned correctly
1 parent 1c53564 commit 82ac432

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Global references are included in ALL projects in this repository
55
-->
66
<ItemGroup>
7-
<GlobalPackageReference Include="Ubiquity.NET.Versioning.Build.Tasks" Version="5.0.5-alpha"/>
7+
<GlobalPackageReference Include="Ubiquity.NET.Versioning.Build.Tasks" Version="5.0.6-alpha"/>
88

99
<!--
1010
NOTE: This analyzer is sadly, perpetually in "pre-release" mode. There have been many issues/discussion on the point

src/Ubiquity.NET.Versioning.UT/CSemVerCITests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ public void ToStringTests( )
192192
var ver_beta = new CSemVerCI( new CSemVer(20, 1, 4, beta_1_0, ["buildMeta"]), testIndex, testName);
193193
var ver_delta = new CSemVerCI( new CSemVer(20, 1, 4, delta_0_1, ["buildMeta"]), testIndex, testName);
194194

195-
Assert.AreEqual("20.1.5-alpha.ci.BuildIndex.BuildName+buildMeta", ver_alpha.ToString());
196-
Assert.AreEqual("20.1.5-beta.1.ci.BuildIndex.BuildName+buildMeta", ver_beta.ToString());
195+
Assert.AreEqual("20.1.5-alpha.0.0.ci.BuildIndex.BuildName+buildMeta", ver_alpha.ToString());
196+
Assert.AreEqual("20.1.5-beta.1.0.ci.BuildIndex.BuildName+buildMeta", ver_beta.ToString());
197197
Assert.AreEqual("20.1.5-delta.0.1.ci.BuildIndex.BuildName+buildMeta", ver_delta.ToString());
198198
}
199199

src/Ubiquity.NET.Versioning.UT/PrereleaseVersionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ public void ToStringTest( )
8181

8282
string[] expectedSeq = ["beta", "0", "0"];
8383
prv = new PrereleaseVersion( "beta", 0, 0 );
84-
Assert.IsTrue( expectedSeq.SequenceEqual( prv.FormatElements( alawaysIncludeZero: true ) ) );
84+
Assert.IsTrue( expectedSeq.SequenceEqual( prv.FormatElements( alwaysIncludeZero: true ) ) );
8585

8686
expectedSeq = ["beta"];
87-
Assert.IsTrue( expectedSeq.SequenceEqual( prv.FormatElements( alawaysIncludeZero: false ) ) );
87+
Assert.IsTrue( expectedSeq.SequenceEqual( prv.FormatElements( alwaysIncludeZero: false ) ) );
8888
}
8989
}
9090
}

src/Ubiquity.NET.Versioning/CSemVerCI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private CSemVerCI( CSemVer patchP1, CSemVer baseBuild, ImmutableArray<string> ci
266266
patchP1.Minor,
267267
patchP1.Patch,
268268
AlphaNumericOrdering.CaseInsensitive,
269-
[ .. patchP1.PreRelease, .. ciSeq ],
269+
[ .. patchP1.PrereleaseVersion?.FormatElements(alwaysIncludeZero: true) ?? patchP1.PreRelease, .. ciSeq ],
270270
patchP1.BuildMeta
271271
)
272272
{

src/Ubiquity.NET.Versioning/PrereleaseVersion.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ public PrereleaseVersion( string preRelName, byte preRelNumber, byte preRelFix )
6868
public string Name => CSemVerPrereleaseGrammar.ValidPrereleaseNames[ Index ];
6969

7070
/// <summary>Gets this <see cref="PrereleaseVersion"/> as a sequence of strings</summary>
71-
/// <param name="alawaysIncludeZero">Indicates whether the result will always include zero values</param>
71+
/// <param name="alwaysIncludeZero">Indicates whether the result will always include zero values</param>
7272
/// <returns>Sequence of strings that represent this instance</returns>
7373
/// <remarks>
7474
/// The default behavior is to skip the <see cref="Number"/> value if it and the <see cref="Fix"/>
75-
/// value are zero. <paramref name="alawaysIncludeZero"/> is used to override this and show the
75+
/// value are zero. <paramref name="alwaysIncludeZero"/> is used to override this and show the
7676
/// zero value always. (Normally this is only used for a <see cref="CSemVerCI"/>)
7777
/// </remarks>
7878
/// <seealso cref="SemVer.PreRelease"/>
7979
/// <seealso cref="CSemVer"/>
8080
/// <seealso cref="CSemVerCI"/>
81-
public IEnumerable<string> FormatElements( bool alawaysIncludeZero = false )
81+
public IEnumerable<string> FormatElements( bool alwaysIncludeZero = false )
8282
{
8383
yield return Name;
84-
if(Number > 0 || Fix > 0 || alawaysIncludeZero)
84+
if(Number > 0 || Fix > 0 || alwaysIncludeZero)
8585
{
8686
yield return Number.ToString( CultureInfo.InvariantCulture );
87-
if(Fix >= 1 || alawaysIncludeZero)
87+
if(Fix >= 1 || alwaysIncludeZero)
8888
{
8989
yield return Fix.ToString( CultureInfo.InvariantCulture );
9090
}

0 commit comments

Comments
 (0)