Skip to content

Commit 2ee6da2

Browse files
committed
Tag comparison was treating stable as higher than pre-release causing patch to bump when it shouldn't
1 parent 28a7c9e commit 2ee6da2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

GitVersionCore/SemanticVersionPreReleaseTag.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ public static SemanticVersionPreReleaseTag Parse(string preReleaseTag)
9797

9898
public int CompareTo(SemanticVersionPreReleaseTag other)
9999
{
100+
if (!HasTag() && other.HasTag())
101+
{
102+
return 1;
103+
}
104+
if (HasTag() && !other.HasTag())
105+
{
106+
return -1;
107+
}
108+
100109
var nameComparison = StringComparer.InvariantCultureIgnoreCase.Compare(Name, other);
101110
if (nameComparison != 0)
102111
return nameComparison;

Tests/SemanticVersionTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public void LegacySemVerTest()
6161
new SemanticVersionPreReleaseTag("AReallyReallyReallyLongBranchName", 1).ToString("lp").ShouldBe("AReallyReallyRea0001");
6262
}
6363

64+
[Test]
65+
public void VersionSorting()
66+
{
67+
SemanticVersion.Parse("1.0.0").ShouldBeGreaterThan(SemanticVersion.Parse("1.0.0-beta"));
68+
}
69+
6470
[Test]
6571
public void EmptyVersion()
6672
{

0 commit comments

Comments
 (0)