Skip to content

Commit

Permalink
Merge pull request #6 from augustoproiete/add-isprerelease-property
Browse files Browse the repository at this point in the history
Add bool IsPreRelease property to MinVerVersion
  • Loading branch information
augustoproiete authored Nov 22, 2020
2 parents f411124 + a4936ac commit 69a2888
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ dotnet tool install --global minver-cli
| Minor | `int` | The minor version number |
| Patch | `int` | The patch version number |
| PreRelease | `string` | The pre-release extension |
| IsPreRelease | `bool` | `true` if `PreRelease` is not null or empty |
| BuildMetadata | `string` | The build metadata extension |
| AssemblyVersion | `string` | `{Major}.0.0.0` |
| FileVersion | `string` | `{Major}.{Minor}.{Patch}.0` |
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.MinVer/MinVerVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public MinVerVersion(string version)
/// </summary>
public string PreRelease { get; }

/// <summary>
/// Returns <see langword="true"/> when <see cref="PreRelease" /> is not null or empty
/// otherwise <see langword="false"/>
/// </summary>
public bool IsPreRelease => !string.IsNullOrWhiteSpace(PreRelease);

/// <summary>
/// The Build metadata extension
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions test/Cake.MinVer.Tests/MinVerVersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,14 @@ public void Should_Convert_to_string_implicitly()
string versionString = new MinVerVersion("1.2.3-alpha.4+abcdefg");
versionString.Should().Be("1.2.3-alpha.4+abcdefg");
}

[Fact]
public void Should_Set_IsPreRelease()
{
new MinVerVersion("1.2.3").IsPreRelease.Should().Be(false);
new MinVerVersion("1.2.3-alpha").IsPreRelease.Should().Be(true);
new MinVerVersion("1.2.3-alpha.4").IsPreRelease.Should().Be(true);
new MinVerVersion("1.2.3-alpha.4+abcdefg").IsPreRelease.Should().Be(true);
}
}
}

0 comments on commit 69a2888

Please sign in to comment.