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

Support Revision Part of version number #962

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3123c76
Changing Version and VersionPart to NuGetVersion
Jan 7, 2024
626588e
Change help string for VersionPart
Jan 7, 2024
b50307e
change Version ToString
Jan 7, 2024
a8e3956
Initial Change to .targets. Maybe change required at MinVerPreRelease…
Jan 7, 2024
650e425
Change and add tests to MinVertests.Lib to account for changed behaviour
Jan 7, 2024
24d589f
Changing Package to accept revision and simple changes to MinVerTests…
Jan 7, 2024
52e0466
Hacking around Sdk.cs not finding .nupkg because it was put in bin/x6…
Jan 7, 2024
f68a378
Changing GetPackage to return four part version number because nuget …
Jan 7, 2024
a77776d
again, error with nupkg being put in x64/Debug
Jan 7, 2024
3d82094
fixing version truncation for product and informational version
Jan 7, 2024
c3ffc01
fixing simple logic error in OutputMasking.cs
Jan 7, 2024
9e62f0b
fixed expected values for OutputVariables.cs
Jan 7, 2024
a136b9b
fixing mistyped comma for dot
Jan 7, 2024
38e7364
update SimpleExec from 12.0.0-beta.1 to 12.0.0-rc.1
adamralph Dec 25, 2023
957e856
Changing Version and VersionPart to NuGetVersion
Juff-Ma Jan 7, 2024
9b136ce
Change help string for VersionPart
Juff-Ma Jan 7, 2024
b29a959
change Version ToString
Juff-Ma Jan 7, 2024
ea2980b
Initial Change to .targets. Maybe change required at MinVerPreRelease…
Juff-Ma Jan 7, 2024
4fc1d43
Change and add tests to MinVertests.Lib to account for changed behaviour
Juff-Ma Jan 7, 2024
927f9b8
Changing Package to accept revision and simple changes to MinVerTests…
Juff-Ma Jan 7, 2024
adfd21c
Hacking around Sdk.cs not finding .nupkg because it was put in bin/x6…
Juff-Ma Jan 7, 2024
e1b833e
Changing GetPackage to return four part version number because nuget …
Juff-Ma Jan 7, 2024
31eda20
again, error with nupkg being put in x64/Debug
Juff-Ma Jan 7, 2024
3e4b6da
fixing version truncation for product and informational version
Juff-Ma Jan 7, 2024
9fe4716
fixing simple logic error in OutputMasking.cs
Juff-Ma Jan 7, 2024
4339445
fixed expected values for OutputVariables.cs
Juff-Ma Jan 7, 2024
37aac29
fixing mistyped comma for dot
Juff-Ma Jan 7, 2024
48da30f
Merge branch 'main' of https://github.com/Juff-Ma/minver-revision
Juff-Ma Jan 7, 2024
8e400ad
remove unnecessary using directive
adamralph Jan 8, 2024
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
26 changes: 14 additions & 12 deletions MinVer.Lib/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@

namespace MinVer.Lib;

public class Version : SemanticVersion
public class Version : NuGetVersion
{
private readonly List<string> preReleaseIdentifiers;
private readonly int height;

public Version(IEnumerable<string> defaultPreReleaseIdentifiers) : this(0, 0, 0, defaultPreReleaseIdentifiers.ToList(), 0, "") { }
public Version(IEnumerable<string> defaultPreReleaseIdentifiers) : this(0, 0, 0, 0, defaultPreReleaseIdentifiers.ToList(), 0, "") { }

private Version(int major, int minor, int patch, List<string> preReleaseIdentifiers, int height, string? buildMetadata) :
private Version(int major, int minor, int patch, int revision, List<string> preReleaseIdentifiers, int height, string? buildMetadata) :
base(
major,
minor,
patch,
revision,
height > 0
? preReleaseIdentifiers.Append(height.ToString(CultureInfo.InvariantCulture))
: preReleaseIdentifiers,
Expand All @@ -29,32 +30,33 @@ private Version(int major, int minor, int patch, List<string> preReleaseIdentifi
}

public override string ToString(string? format, IFormatProvider? formatProvider) =>
$"{this.Major}.{this.Minor}.{this.Patch}{(string.IsNullOrEmpty(this.Release) ? "" : $"-{this.Release}")}{(string.IsNullOrEmpty(this.Metadata) ? "" : $"+{this.Metadata}")}";
$"{this.Major}.{this.Minor}.{this.Patch}.{this.Revision}{(string.IsNullOrEmpty(this.Release) ? "" : $"-{this.Release}")}{(string.IsNullOrEmpty(this.Metadata) ? "" : $"+{this.Metadata}")}";

public Version Satisfying(MajorMinor minMajorMinor, IEnumerable<string> defaultPreReleaseIdentifiers)
{
minMajorMinor = minMajorMinor ?? throw new ArgumentNullException(nameof(minMajorMinor));

return minMajorMinor.Major < this.Major || (minMajorMinor.Major == this.Major && minMajorMinor.Minor <= this.Minor)
? this
: new Version(minMajorMinor.Major, minMajorMinor.Minor, 0, defaultPreReleaseIdentifiers.ToList(), this.height, this.Metadata);
: new Version(minMajorMinor.Major, minMajorMinor.Minor, 0, 0, defaultPreReleaseIdentifiers.ToList(), this.height, this.Metadata);
}

public Version WithHeight(int newHeight, VersionPart autoIncrement, IEnumerable<string> defaultPreReleaseIdentifiers) =>
this.preReleaseIdentifiers.Count == 0 && newHeight > 0
? autoIncrement switch
{
VersionPart.Major => new Version(this.Major + 1, 0, 0, defaultPreReleaseIdentifiers.ToList(), newHeight, ""),
VersionPart.Minor => new Version(this.Major, this.Minor + 1, 0, defaultPreReleaseIdentifiers.ToList(), newHeight, ""),
VersionPart.Patch => new Version(this.Major, this.Minor, this.Patch + 1, defaultPreReleaseIdentifiers.ToList(), newHeight, ""),
VersionPart.Major => new Version(this.Major + 1, 0, 0, 0, defaultPreReleaseIdentifiers.ToList(), newHeight, ""),
VersionPart.Minor => new Version(this.Major, this.Minor + 1, 0, 0, defaultPreReleaseIdentifiers.ToList(), newHeight, ""),
VersionPart.Patch => new Version(this.Major, this.Minor, this.Patch + 1, 0, defaultPreReleaseIdentifiers.ToList(), newHeight, ""),
VersionPart.Revision => new Version(this.Major, this.Minor, this.Patch, this.Revision + 1, defaultPreReleaseIdentifiers.ToList(), newHeight, ""),
_ => throw new ArgumentOutOfRangeException(nameof(autoIncrement)),
}
: new Version(this.Major, this.Minor, this.Patch, this.preReleaseIdentifiers, newHeight, newHeight == 0 ? this.Metadata : "");
: new Version(this.Major, this.Minor, this.Patch, this.Revision, this.preReleaseIdentifiers, newHeight, newHeight == 0 ? this.Metadata : "");

public Version AddBuildMetadata(string newBuildMetadata)
{
var separator = !string.IsNullOrEmpty(this.Metadata) && !string.IsNullOrEmpty(newBuildMetadata) ? "." : "";
return new Version(this.Major, this.Minor, this.Patch, this.preReleaseIdentifiers, this.height, $"{this.Metadata}{separator}{newBuildMetadata}");
return new Version(this.Major, this.Minor, this.Patch, this.Revision, this.preReleaseIdentifiers, this.height, $"{this.Metadata}{separator}{newBuildMetadata}");
}

public static bool TryParse(string text, [NotNullWhen(returnValue: true)] out Version? version, string prefix = "")
Expand All @@ -69,12 +71,12 @@ public static bool TryParse(string text, [NotNullWhen(returnValue: true)] out Ve
return false;
}

if (!SemanticVersion.TryParse(text[prefix.Length..], out var semanticVersion))
if (!NuGetVersion.TryParse(text[prefix.Length..], out var nugetVersion))
{
return false;
}

version = new Version(semanticVersion.Major, semanticVersion.Minor, semanticVersion.Patch, semanticVersion.ReleaseLabels.ToList(), 0, semanticVersion.Metadata);
version = new Version(nugetVersion.Major, nugetVersion.Minor, nugetVersion.Patch, nugetVersion.Revision, nugetVersion.ReleaseLabels.ToList(), 0, nugetVersion.Metadata);
return true;
}
}
9 changes: 5 additions & 4 deletions MinVer.Lib/VersionPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ namespace MinVer.Lib;

public enum VersionPart
{
Patch = 0,
Minor = 1,
Major = 2,
Revision = 0,
Patch = 1,
Minor = 2,
Major = 3,
}

public static class VersionPartExtensions
{
public static string ValidValues => "major, minor, or patch (default)";
public static string ValidValues => "major, minor, patch or revision (default)";
}
8 changes: 5 additions & 3 deletions MinVer/build/MinVer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,24 @@
<MinVerVersion>@(MinVerOutputVersion)</MinVerVersion>
<MinVerMajor>$(MinVerVersion.Split(`.`)[0])</MinVerMajor>
<MinVerMinor>$(MinVerVersion.Split(`.`)[1])</MinVerMinor>
<MinVerPatch>$(MinVerVersion.Split(`.`)[2].Split(`-`)[0].Split(`+`)[0])</MinVerPatch>
<MinVerPatch>$(MinVerVersion.Split(`.`)[2])</MinVerPatch>
<MinVerRevision>$(MinVerVersion.Split(`.`)[3].Split(`-`)[0].Split(`+`)[0])</MinVerRevision>
<MinVerPreRelease></MinVerPreRelease>
<MinVerPreRelease Condition="$(MinVerVersion.Split(`+`)[0].Contains(`-`))">$(MinVerVersion.Split(`+`)[0].Split(`-`, 2)[1])</MinVerPreRelease>
<MinVerBuildMetadata></MinVerBuildMetadata>
<MinVerBuildMetadata Condition="$(MinVerVersion.Contains(`+`))">$(MinVerVersion.Split(`+`, 2)[1])</MinVerBuildMetadata>
<AssemblyVersion>$(MinVerMajor).0.0.0</AssemblyVersion>
<FileVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0</FileVersion>
<FileVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(MinVerRevision)</FileVersion>
<InformationalVersion>$(MinVerVersion)</InformationalVersion>
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)</PackageVersion>
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(MinVerRevision)</PackageVersion>
<PackageVersion Condition="'$(MinVerPreRelease)' != ''">$(PackageVersion)-$(MinVerPreRelease)</PackageVersion>
<Version>$(PackageVersion)</Version>
</PropertyGroup>
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] MinVerVersion=$(MinVerVersion)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] MinVerMajor=$(MinVerMajor)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] MinVerMinor=$(MinVerMinor)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] MinVerPatch=$(MinVerPatch)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] MinVerRevision=$(MinVerRevision)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] MinVerPreRelease=$(MinVerPreRelease)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] MinVerBuildMetadata=$(MinVerBuildMetadata)" />
<Message Importance="$(MinVerDetailed)" Text="MinVer: [output] AssemblyVersion=$(AssemblyVersion)" />
Expand Down
6 changes: 3 additions & 3 deletions MinVerTests.Infra/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ namespace MinVerTests.Infra;

public record Package(string Version, AssemblyVersion AssemblyVersion, FileVersion FileVersion, string InformationalVersion)
{
public static Package WithVersion(int major, int minor, int patch, IEnumerable<string>? preReleaseIdentifiers = null, int height = 0, string buildMetadata = "", string? informationalVersionAdditionalBuildMetadata = "")
public static Package WithVersion(int major, int minor, int patch, int revision, IEnumerable<string>? preReleaseIdentifiers = null, int height = 0, string buildMetadata = "", string? informationalVersionAdditionalBuildMetadata = "")
{
var preReleaseToken = preReleaseIdentifiers == null ? "" : GetPreReleaseToken(preReleaseIdentifiers.ToList());
var heightToken = height == 0 ? "" : $".{height}";
var buildMetadataToken = string.IsNullOrEmpty(buildMetadata) ? "" : $"+{buildMetadata}";

var version = $"{major}.{minor}.{patch}{preReleaseToken}{heightToken}";
var version = $"{major}.{minor}.{patch}.{revision}{preReleaseToken}{heightToken}";
var informationalVersion = $"{version}{buildMetadataToken}{informationalVersionAdditionalBuildMetadata}";

return new Package(version, new AssemblyVersion(major, 0, 0, 0), new FileVersion(major, minor, patch, 0, informationalVersion), informationalVersion);
return new Package(version, new AssemblyVersion(major, 0, 0, 0), new FileVersion(major, minor, patch, revision, informationalVersion), informationalVersion);
}

private static string GetPreReleaseToken(IReadOnlyList<string> preReleaseIdentifiers) => preReleaseIdentifiers.Any() ? $"-{string.Join(".", preReleaseIdentifiers)}" : "";
Expand Down
31 changes: 28 additions & 3 deletions MinVerTests.Infra/Sdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ private static void CreateGlobalJsonIfRequired(string path)
environmentVariables,
handleExitCode).ConfigureAwait(false);

var matcher = new Matcher().AddInclude("**/bin/Debug/*.nupkg");
//very weird, it always put the file in bin/x64/Debug and not bin/Debug changed it for now
var matcher = new Matcher().AddInclude("**/Debug/*.nupkg");
var packageFileNames = matcher.GetResultsInFullPath(path).OrderBy(result => result);
var getPackages = packageFileNames.Select(GetPackage);
var packages = await Task.WhenAll(getPackages).ConfigureAwait(false);
Expand Down Expand Up @@ -184,15 +185,39 @@ private static async Task<Package> GetPackage(string fileName)
var nuspecFileName = Directory.EnumerateFiles(extractedDirectoryName, "*.nuspec").First();

var nuspec = await File.ReadAllTextAsync(nuspecFileName).ConfigureAwait(false);
var nuspecVersion = nuspec.Split("<version>")[1].Split("</version>")[0];

//adding Revision part to value got from nuget because of automatic truncation by nuget (i have a feeling this could be done better)
var nuspecVersionRaw = nuspec.Split("<version>")[1].Split("</version>")[0];
var nuspecVersionParts = nuspecVersionRaw.Split('-', 2);
var containsRevision = nuspecVersionParts[0].Count(c => c == '.') > 2;
string nuspecVersion;
if (containsRevision)
{
nuspecVersion = nuspecVersionRaw;
}
else
{
nuspecVersion = $"{nuspecVersionParts[0]}.0";
nuspecVersion += nuspecVersionParts.Length > 1 ? $"-{nuspecVersionParts[1]}" : string.Empty;
}

var assemblyFileName = Directory.EnumerateFiles(extractedDirectoryName, "*.dll", new EnumerationOptions { RecurseSubdirectories = true, }).First();

var (systemAssemblyVersion, informationalVersion) = GetAssemblyVersions(assemblyFileName);
//also changing informational version because of automatic truncation
if (informationalVersion.Count(c => c == '.') < 3)
{
informationalVersion += ".0";
}

var assemblyVersion = new AssemblyVersion(systemAssemblyVersion.Major, systemAssemblyVersion.Minor, systemAssemblyVersion.Build, systemAssemblyVersion.Revision);

var fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyFileName);
var fileVersion = new FileVersion(fileVersionInfo.FileMajorPart, fileVersionInfo.FileMinorPart, fileVersionInfo.FileBuildPart, fileVersionInfo.FilePrivatePart, fileVersionInfo.ProductVersion ?? "");
//also changing product version because of automatic truncation
var productVersion = fileVersionInfo.ProductVersion?.Count(c => c == '.') < 3
? $"{fileVersionInfo.ProductVersion}.0"
: fileVersionInfo.ProductVersion;
var fileVersion = new FileVersion(fileVersionInfo.FileMajorPart, fileVersionInfo.FileMinorPart, fileVersionInfo.FileBuildPart, fileVersionInfo.FilePrivatePart, productVersion ?? "");

return new Package(nuspecVersion, assemblyVersion, fileVersion, informationalVersion);
}
Expand Down
11 changes: 8 additions & 3 deletions MinVerTests.Lib/AutoIncrement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ namespace MinVerTests.Lib;
public static class AutoIncrement
{
[Theory]
[InlineData("1.2.3", VersionPart.Major, "2.0.0-alpha.0.1")]
[InlineData("1.2.3", VersionPart.Minor, "1.3.0-alpha.0.1")]
[InlineData("1.2.3", VersionPart.Patch, "1.2.4-alpha.0.1")]
[InlineData("1.2.3.4", VersionPart.Major, "2.0.0.0-alpha.0.1")]
[InlineData("1.2.3.4", VersionPart.Minor, "1.3.0.0-alpha.0.1")]
[InlineData("1.2.3.4", VersionPart.Patch, "1.2.4.0-alpha.0.1")]
[InlineData("1.2.3.4", VersionPart.Revision, "1.2.3.5-alpha.0.1")]
[InlineData("1.2.3", VersionPart.Major, "2.0.0.0-alpha.0.1")]
[InlineData("1.2.3", VersionPart.Minor, "1.3.0.0-alpha.0.1")]
[InlineData("1.2.3", VersionPart.Patch, "1.2.4.0-alpha.0.1")]
[InlineData("1.2.3", VersionPart.Revision, "1.2.3.1-alpha.0.1")]
public static async Task RtmVersionIncrement(string tag, VersionPart autoIncrement, string expectedVersion)
{
// arrange
Expand Down
37 changes: 21 additions & 16 deletions MinVerTests.Lib/BuildMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace MinVerTests.Lib;
public static class BuildMetadata
{
[Theory]
[InlineData("", "0.0.0-alpha.0")]
[InlineData("a", "0.0.0-alpha.0+a")]
[InlineData("", "0.0.0.0-alpha.0")]
[InlineData("a", "0.0.0.0-alpha.0+a")]
public static async Task NoCommits(string buildMetadata, string expectedVersion)
{
// arrange
Expand All @@ -27,8 +27,8 @@ public static async Task NoCommits(string buildMetadata, string expectedVersion)
}

[Theory]
[InlineData("", "0.0.0-alpha.0")]
[InlineData("a", "0.0.0-alpha.0+a")]
[InlineData("", "0.0.0.0-alpha.0")]
[InlineData("a", "0.0.0.0-alpha.0+a")]
public static async Task NoTag(string buildMetadata, string expectedVersion)
{
// arrange
Expand All @@ -43,12 +43,15 @@ public static async Task NoTag(string buildMetadata, string expectedVersion)
}

[Theory]
[InlineData("1.2.3+a", "", "1.2.3+a")]
[InlineData("1.2.3", "b", "1.2.3+b")]
[InlineData("1.2.3+a", "b", "1.2.3+a.b")]
[InlineData("1.2.3-pre+a", "", "1.2.3-pre+a")]
[InlineData("1.2.3-pre", "b", "1.2.3-pre+b")]
[InlineData("1.2.3-pre+a", "b", "1.2.3-pre+a.b")]
[InlineData("1.2.3.4+a", "", "1.2.3.4+a")]
[InlineData("1.2.3.4", "b", "1.2.3.4+b")]
[InlineData("1.2.3.4+a", "b", "1.2.3.4+a.b")]
[InlineData("1.2.3.4-pre+a", "", "1.2.3.4-pre+a")]
[InlineData("1.2.3.4-pre", "b", "1.2.3.4-pre+b")]
[InlineData("1.2.3.4-pre+a", "b", "1.2.3.4-pre+a.b")]
[InlineData("1.2.3-pre+a", "b", "1.2.3.0-pre+a.b")]
[InlineData("1.2.3+a", "b", "1.2.3.0+a.b")]
[InlineData("1.2.3", "b", "1.2.3.0+b")]
public static async Task CurrentTag(string tag, string buildMetadata, string expectedVersion)
{
// arrange
Expand All @@ -64,12 +67,14 @@ public static async Task CurrentTag(string tag, string buildMetadata, string exp
}

[Theory]
[InlineData("1.2.3+a", "", "1.2.4-alpha.0.1")]
[InlineData("1.2.3", "b", "1.2.4-alpha.0.1+b")]
[InlineData("1.2.3+a", "b", "1.2.4-alpha.0.1+b")]
[InlineData("1.2.3-pre+a", "", "1.2.3-pre.1")]
[InlineData("1.2.3-pre", "b", "1.2.3-pre.1+b")]
[InlineData("1.2.3-pre+a", "b", "1.2.3-pre.1+b")]
[InlineData("1.2.3.4+a", "", "1.2.3.5-alpha.0.1")]
[InlineData("1.2.3.4", "b", "1.2.3.5-alpha.0.1+b")]
[InlineData("1.2.3.4+a", "b", "1.2.3.5-alpha.0.1+b")]
[InlineData("1.2.3.4-pre+a", "", "1.2.3.4-pre.1")]
[InlineData("1.2.3.4-pre", "b", "1.2.3.4-pre.1+b")]
[InlineData("1.2.3.4-pre+a", "b", "1.2.3.4-pre.1+b")]
[InlineData("1.2.3-pre+a", "b", "1.2.3.0-pre.1+b")]
[InlineData("1.2.3", "b", "1.2.3.1-alpha.0.1+b")]
public static async Task PreviousTag(string tag, string buildMetadata, string expectedVersion)
{
// arrange
Expand Down
4 changes: 2 additions & 2 deletions MinVerTests.Lib/DefaultPreReleaseIdentifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace MinVerTests.Lib;
public static class DefaultPreReleaseIdentifiers
{
[Theory]
[InlineData("alpha.0", "0.0.0-alpha.0")]
[InlineData("preview.x", "0.0.0-preview.x")]
[InlineData("alpha.0", "0.0.0.0-alpha.0")]
[InlineData("preview.x", "0.0.0.0-preview.x")]
public static async Task Various(string identifiers, string expectedVersion)
{
// arrange
Expand Down
13 changes: 8 additions & 5 deletions MinVerTests.Lib/MinMajorMinor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ public static async Task NoCommits()
var actualVersion = Versioner.GetVersion(path, "", new MajorMinor(1, 2), "", default, PreReleaseIdentifiers.Default, false, NullLogger.Instance);

// assert
Assert.Equal("1.2.0-alpha.0", actualVersion.ToString());
Assert.Equal("1.2.0.0-alpha.0", actualVersion.ToString());
}

[Theory]
[InlineData("4.0.0", 3, 2, "4.0.0", true)]
[InlineData("4.3.0", 4, 3, "4.3.0", true)]
[InlineData("4.3.0", 5, 4, "5.4.0-alpha.0", false)]
[InlineData("4.0.0.0", 3, 2, "4.0.0.0", true)]
[InlineData("4.3.0.0", 4, 3, "4.3.0.0", true)]
[InlineData("4.3.0.0", 5, 4, "5.4.0.0-alpha.0", false)]
[InlineData("4.0.0", 3, 2, "4.0.0.0", true)]
[InlineData("4.3.0", 4, 3, "4.3.0.0", true)]
[InlineData("4.3.0", 5, 6, "5.6.0.0-alpha.0", false)]
public static async Task Tagged(string tag, int major, int minor, string expectedVersion, bool isRedundant)
{
// arrange
Expand Down Expand Up @@ -60,6 +63,6 @@ public static async Task NotTagged()
var actualVersion = Versioner.GetVersion(path, "", new MajorMinor(1, 0), "", default, PreReleaseIdentifiers.Default, false, NullLogger.Instance);

// assert
Assert.Equal("1.0.0-alpha.0", actualVersion.ToString());
Assert.Equal("1.0.0.0-alpha.0", actualVersion.ToString());
}
}
9 changes: 6 additions & 3 deletions MinVerTests.Lib/TagPrefixes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ namespace MinVerTests.Lib;
public static class TagPrefixes
{
[Theory]
[InlineData("2.3.4", "", "2.3.4")]
[InlineData("v3.4.5", "v", "3.4.5")]
[InlineData("version5.6.7", "version", "5.6.7")]
[InlineData("2.3.4.5", "", "2.3.4.5")]
[InlineData("v3.4.5.8", "v", "3.4.5.8")]
[InlineData("version5.6.7.15", "version", "5.6.7.15")]
[InlineData("2.3.4", "", "2.3.4.0")]
[InlineData("r3.4.5", "r", "3.4.5.0")]
[InlineData("revision5.6.7", "revision", "5.6.7.0")]
public static async Task TagPrefix(string tag, string prefix, string expectedVersion)
{
// act
Expand Down
4 changes: 2 additions & 2 deletions MinVerTests.Lib/Versions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static async Task EmptyRepo()
var version = Versioner.GetVersion(path, "", MajorMinor.Default, "", default, PreReleaseIdentifiers.Default, false, NullLogger.Instance);

// assert
Assert.Equal("0.0.0-alpha.0", version.ToString());
Assert.Equal("0.0.0.0-alpha.0", version.ToString());
}

[Fact]
Expand All @@ -130,6 +130,6 @@ public static void NoRepo()
var version = Versioner.GetVersion(path, "", MajorMinor.Default, "", default, PreReleaseIdentifiers.Default, false, NullLogger.Instance);

// assert
Assert.Equal("0.0.0-alpha.0", version.ToString());
Assert.Equal("0.0.0.0-alpha.0", version.ToString());
}
}
Loading
Loading