Skip to content

Commit 140b790

Browse files
committed
Fixed small issue with new parser
1 parent f459594 commit 140b790

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using GitVersion;
22
using LibGit2Sharp;
33
using NUnit.Framework;
4-
using Shouldly;
54

65
[TestFixture]
76
public class MasterScenarios

GitVersionCore.Tests/SemanticVersionTests.cs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,35 @@
66
public class SemanticVersionTests
77
{
88

9-
[TestCase("1.2.3", 1, 2, 3, null, null, null, null, null, null, null)]
10-
[TestCase("1.2", 1, 2, 0, null, null, null, null, null, null, "1.2.0")]
11-
[TestCase("1.2.3-beta", 1, 2, 3, "beta", null, null, null, null, null, null)]
12-
[TestCase("1.2.3-beta3", 1, 2, 3, "beta", 3, null, null, null, null, "1.2.3-beta.3")]
13-
[TestCase("1.2.3-beta.3", 1, 2, 3, "beta", 3, null, null, null, null, "1.2.3-beta.3")]
14-
[TestCase("1.2.3-beta-3", 1, 2, 3, "beta-3", null, null, null, null, null, "1.2.3-beta-3")]
15-
[TestCase("1.2.3-alpha", 1, 2, 3, "alpha", null, null, null, null, null, null)]
16-
[TestCase("1.2-alpha4", 1, 2, 0, "alpha", 4, null, null, null, null, "1.2.0-alpha.4")]
17-
[TestCase("1.2.3-rc", 1, 2, 3, "rc", null, null, null, null, null, null)]
18-
[TestCase("1.2.3-rc3", 1, 2, 3, "rc", 3, null, null, null, null, "1.2.3-rc.3")]
19-
[TestCase("1.2.3-RC3", 1, 2, 3, "RC", 3, null, null, null, null, "1.2.3-RC.3")]
20-
[TestCase("1.2.3-rc3.1", 1, 2, 3, "rc3", 1, null, null, null, null, "1.2.3-rc3.1")]
21-
[TestCase("01.02.03-rc03", 1, 2, 3, "rc", 3, null, null, null, null, "1.2.3-rc.3")]
22-
[TestCase("1.2.3-beta3f", 1, 2, 3, "beta3f", null, null, null, null, null, null)]
23-
[TestCase("1.2.3-notAStability1", 1, 2, 3, "notAStability", 1, null, null, null, null, "1.2.3-notAStability.1")]
24-
[TestCase("1.2.3.4", 1, 2, 3, null, null, 4, null, null, null, "1.2.3+4")]
25-
[TestCase("1.2.3+4", 1, 2, 3, null, null, 4, null, null, null, null)]
26-
[TestCase("1.2.3+4.Branch.Foo", 1, 2, 3, null, null, 4, "Foo", null, null, null)]
27-
[TestCase("1.2.3+randomMetaData", 1, 2, 3, null, null, null, null, null, "randomMetaData", null)]
28-
[TestCase("1.2.3-beta.1+4.Sha.12234.Othershiz", 1, 2, 3, "beta", 1, 4, null, "12234", "Othershiz", null)]
29-
public void ValidateVersionParsing(string versionString, int major, int minor, int patch, string tag, int? tagNumber, int? numberOfBuilds,
30-
string branchName, string sha, string otherMetaData, string fullFormattedVersionString)
9+
[TestCase("1.2.3", 1, 2, 3, null, null, null, null, null, null, null, null)]
10+
[TestCase("1.2", 1, 2, 0, null, null, null, null, null, null, "1.2.0", null)]
11+
[TestCase("1.2.3-beta", 1, 2, 3, "beta", null, null, null, null, null, null, null)]
12+
[TestCase("1.2.3-beta3", 1, 2, 3, "beta", 3, null, null, null, null, "1.2.3-beta.3", null)]
13+
[TestCase("1.2.3-beta.3", 1, 2, 3, "beta", 3, null, null, null, null, "1.2.3-beta.3", null)]
14+
[TestCase("1.2.3-beta-3", 1, 2, 3, "beta-3", null, null, null, null, null, "1.2.3-beta-3", null)]
15+
[TestCase("1.2.3-alpha", 1, 2, 3, "alpha", null, null, null, null, null, null, null)]
16+
[TestCase("1.2-alpha4", 1, 2, 0, "alpha", 4, null, null, null, null, "1.2.0-alpha.4", null)]
17+
[TestCase("1.2.3-rc", 1, 2, 3, "rc", null, null, null, null, null, null, null)]
18+
[TestCase("1.2.3-rc3", 1, 2, 3, "rc", 3, null, null, null, null, "1.2.3-rc.3", null)]
19+
[TestCase("1.2.3-RC3", 1, 2, 3, "RC", 3, null, null, null, null, "1.2.3-RC.3", null)]
20+
[TestCase("1.2.3-rc3.1", 1, 2, 3, "rc3", 1, null, null, null, null, "1.2.3-rc3.1", null)]
21+
[TestCase("01.02.03-rc03", 1, 2, 3, "rc", 3, null, null, null, null, "1.2.3-rc.3", null)]
22+
[TestCase("1.2.3-beta3f", 1, 2, 3, "beta3f", null, null, null, null, null, null, null)]
23+
[TestCase("1.2.3-notAStability1", 1, 2, 3, "notAStability", 1, null, null, null, null, "1.2.3-notAStability.1", null)]
24+
[TestCase("1.2.3.4", 1, 2, 3, null, null, 4, null, null, null, "1.2.3+4", null)]
25+
[TestCase("1.2.3+4", 1, 2, 3, null, null, 4, null, null, null, null, null)]
26+
[TestCase("1.2.3+4.Branch.Foo", 1, 2, 3, null, null, 4, "Foo", null, null, null, null)]
27+
[TestCase("1.2.3+randomMetaData", 1, 2, 3, null, null, null, null, null, "randomMetaData", null, null)]
28+
[TestCase("1.2.3-beta.1+4.Sha.12234.Othershiz", 1, 2, 3, "beta", 1, 4, null, "12234", "Othershiz", null, null)]
29+
[TestCase("1.2.3", 1, 2, 3, null, null, null, null, null, null, null, "v")]
30+
public void ValidateVersionParsing(
31+
string versionString, int major, int minor, int patch, string tag, int? tagNumber, int? numberOfBuilds,
32+
string branchName, string sha, string otherMetaData, string fullFormattedVersionString, string tagPrefixRegex)
3133
{
3234
fullFormattedVersionString = fullFormattedVersionString ?? versionString;
3335

3436
SemanticVersion version;
35-
Assert.IsTrue(SemanticVersion.TryParse(versionString, null, out version), "TryParse Result");
37+
SemanticVersion.TryParse(versionString, tagPrefixRegex, out version).ShouldBe(true, versionString);
3638
Assert.AreEqual(major, version.Major);
3739
Assert.AreEqual(minor, version.Minor);
3840
Assert.AreEqual(patch, version.Patch);

GitVersionCore/SemanticVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static SemanticVersion Parse(string version, string tagPrefixRegex)
147147

148148
public static bool TryParse(string version, string tagPrefixRegex, out SemanticVersion semanticVersion)
149149
{
150-
var match = Regex.Match(version, string.Format("^({0})(?<version>.*)$", tagPrefixRegex));
150+
var match = Regex.Match(version, string.Format("^({0})?(?<version>.*)$", tagPrefixRegex));
151151

152152
if (!match.Success)
153153
{

0 commit comments

Comments
 (0)