Skip to content

Commit ce13ec2

Browse files
arturcicFrode
authored and
Frode
committed
Move comparison into SemanticVersion
1 parent eb64a28 commit ce13ec2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/GitVersionCore/SemanticVersioning/SemanticVersion.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ public static bool TryParse(string version, string tagPrefixRegex, out SemanticV
184184
}
185185

186186
public int CompareTo(SemanticVersion value)
187+
{
188+
return CompareTo(value, true);
189+
}
190+
191+
public int CompareTo(SemanticVersion value, bool includePrerelease)
187192
{
188193
if (value == null)
189194
{
@@ -213,7 +218,7 @@ public int CompareTo(SemanticVersion value)
213218
}
214219
return -1;
215220
}
216-
if (PreReleaseTag != value.PreReleaseTag)
221+
if (includePrerelease && PreReleaseTag != value.PreReleaseTag)
217222
{
218223
if (PreReleaseTag > value.PreReleaseTag)
219224
{

src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ public SemanticVersion FindVersion(GitVersionContext context)
6666
if (taggedSemanticVersion != null)
6767
{
6868
// replace calculated version with tagged version only if tagged version greater or equal to calculated version
69-
if (semver.Major > taggedSemanticVersion.Major ||
70-
(semver.Major == taggedSemanticVersion.Major && semver.Minor > taggedSemanticVersion.Minor) ||
71-
(semver.Major == taggedSemanticVersion.Major && semver.Minor == taggedSemanticVersion.Minor && semver.Patch > taggedSemanticVersion.Patch))
69+
if (semver.CompareTo(taggedSemanticVersion, false) > 0)
7270
{
7371
taggedSemanticVersion = null;
7472
}

0 commit comments

Comments
 (0)