Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: do not trim version name with strict mode #61

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/SemanticVersioning/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ public class Version : IComparable<Version>, IComparable, IEquatable<Version>
public bool IsPreRelease { get { return !string.IsNullOrEmpty(_preRelease); } }

private static Regex strictRegex = new Regex(@"^
\s*
([0-9]|[1-9][0-9]+) # major version
\.
([0-9]|[1-9][0-9]+) # minor version
\.
([0-9]|[1-9][0-9]+) # patch version
(\-([0-9A-Za-z\-\.]+))? # pre-release version
(\+([0-9A-Za-z\-\.]+))? # build metadata
\s*
$",
RegexOptions.IgnorePatternWhitespace);

Expand Down
21 changes: 9 additions & 12 deletions test/SemanticVersioning.Tests/ParseMajorMinorPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ public class ParseMajorMinorPatch
{
[Theory]
[InlineData("1.2.3", 1, false)]
[InlineData(" 1.2.3 ", 1, false)]
[InlineData(" 2.2.3-4 ", 2, false)]
[InlineData(" 3.2.3-pre ", 3, false)]
[InlineData("\t13.2.3", 13, false)]
[InlineData("2.2.3-4", 2, false)]
[InlineData("3.2.3-pre", 3, false)]
[InlineData("\t13.2.3", 13, true)]
[InlineData(" v8.2.3 ", 8, true)]
[InlineData("v5.2.3", 5, true)]
[InlineData("=21.2.3", 21, true)]
Expand All @@ -23,10 +22,9 @@ public void ParseMajorVersion(string versionString, int majorVersion, bool loose

[Theory]
[InlineData("1.2.3", 2, false)]
[InlineData(" 1.2.3 ", 2, false)]
[InlineData(" 2.2.3-4 ", 2, false)]
[InlineData(" 3.2.3-pre ", 2, false)]
[InlineData("\t13.2.3", 2, false)]
[InlineData("2.2.3-4", 2, false)]
[InlineData("3.2.3-pre", 2, false)]
[InlineData("\t13.2.3", 2, true)]
[InlineData(" v8.2.3 ", 2, true)]
[InlineData("v5.2.3", 2, true)]
[InlineData("=21.2.3", 2, true)]
Expand All @@ -39,10 +37,9 @@ public void ParseMinorVersion(string versionString, int minorVersion, bool loose

[Theory]
[InlineData("1.2.3", 3, false)]
[InlineData(" 1.2.3 ", 3, false)]
[InlineData(" 2.2.3-4 ", 3, false)]
[InlineData(" 3.2.3-pre ", 3, false)]
[InlineData("\t13.2.3", 3, false)]
[InlineData("2.2.3-4", 3, false)]
[InlineData("3.2.3-pre", 3, false)]
[InlineData("13.2.3", 3, false)]
[InlineData(" v8.2.3 ", 3, true)]
[InlineData("v5.2.3", 3, true)]
[InlineData("=21.2.3", 3, true)]
Expand Down
5 changes: 0 additions & 5 deletions test/SemanticVersioning.Tests/VersionComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,39 +189,34 @@ public void Comparisons(string v0s, string v1s)
[InlineData("1.2.3", "=1.2.3", true)]
[InlineData("1.2.3", " 1.2.3", true)]
[InlineData("1.2.3", "= 1.2.3", true)]
[InlineData("1.2.3", " 1.2.3", false)]
[InlineData("1.2.3", " =1.2.3", true)]
[InlineData("1.2.3", " v 1.2.3", true)]
[InlineData("1.2.3", " = 1.2.3", true)]
[InlineData("1.2.3-0", "1.2.3-0", false)]
[InlineData("1.2.3-0", "=1.2.3-0", true)]
[InlineData("1.2.3-0", " 1.2.3-0", true)]
[InlineData("1.2.3-0", "= 1.2.3-0", true)]
[InlineData("1.2.3-0", " 1.2.3-0", false)]
[InlineData("1.2.3-0", " =1.2.3-0", true)]
[InlineData("1.2.3-0", " v 1.2.3-0", true)]
[InlineData("1.2.3-0", " = 1.2.3-0", true)]
[InlineData("1.2.3-1", "1.2.3-1", false)]
[InlineData("1.2.3-1", "=1.2.3-1", true)]
[InlineData("1.2.3-1", " 1.2.3-1", true)]
[InlineData("1.2.3-1", "= 1.2.3-1", true)]
[InlineData("1.2.3-1", " 1.2.3-1", false)]
[InlineData("1.2.3-1", " =1.2.3-1", true)]
[InlineData("1.2.3-1", " v 1.2.3-1", true)]
[InlineData("1.2.3-1", " = 1.2.3-1", true)]
[InlineData("1.2.3-beta", "1.2.3-beta", false)]
[InlineData("1.2.3-beta", "=1.2.3-beta", true)]
[InlineData("1.2.3-beta", " 1.2.3-beta", true)]
[InlineData("1.2.3-beta", "= 1.2.3-beta", true)]
[InlineData("1.2.3-beta", " 1.2.3-beta", false)]
[InlineData("1.2.3-beta", " =1.2.3-beta", true)]
[InlineData("1.2.3-beta", " v 1.2.3-beta", true)]
[InlineData("1.2.3-beta", " = 1.2.3-beta", true)]
[InlineData("1.2.3-beta+build", " = 1.2.3-beta+otherbuild", true)]
[InlineData("1.2.3+build", " = 1.2.3+otherbuild", true)]
[InlineData("1.2.3-beta+build", "1.2.3-beta+otherbuild", false)]
[InlineData("1.2.3+build", "1.2.3+otherbuild", false)]
[InlineData(" 1.2.3+build", "1.2.3+otherbuild", false)]
public void Equality(string v0s, string v1s, bool loose)
{
var v0 = new Version(v0s, false);
Expand Down