Skip to content

Commit

Permalink
Merge pull request #981 from adamralph/refactor
Browse files Browse the repository at this point in the history
minor refactoring
  • Loading branch information
adamralph authored Feb 11, 2024
2 parents 5044a13 + 2fade35 commit 11c0e64
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions MinVer.Lib/Versioner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static (Version Version, int? Height) GetVersion(string workDir, string
return (selectedCandidate.Version, selectedCandidate.Height);
}

private static List<Candidate> GetCandidates(Commit head, IEnumerable<(string Name, string Sha)> tags, string tagPrefix, List<string> defaultPreReleaseIdentifiers, ILogger log)
private static List<Candidate> GetCandidates(Commit head, IEnumerable<(string Name, string Sha)> tags, string tagPrefix, IReadOnlyCollection<string> defaultPreReleaseIdentifiers, ILogger log)
{
var tagsAndVersions = new List<(string Name, string Sha, Version Version)>();

Expand All @@ -97,7 +97,7 @@ private static List<Candidate> GetCandidates(Commit head, IEnumerable<(string Na
[
.. tagsAndVersions
.OrderBy(tagAndVersion => tagAndVersion.Version)
.ThenBy(tagsAndVersion => tagsAndVersion.Name)
.ThenBy(tagsAndVersion => tagsAndVersion.Name),
];

var itemsToCheck = new Stack<(Commit Commit, int Height, Commit? Child)>();
Expand Down
10 changes: 4 additions & 6 deletions MinVer/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ namespace MinVer;

internal sealed class Logger(Verbosity verbosity) : ILogger
{
private readonly Verbosity verbosity = verbosity;
public bool IsTraceEnabled => verbosity >= Verbosity.Diagnostic;

public bool IsTraceEnabled => this.verbosity >= Verbosity.Diagnostic;
public bool IsDebugEnabled => verbosity >= Verbosity.Detailed;

public bool IsDebugEnabled => this.verbosity >= Verbosity.Detailed;

public bool IsInfoEnabled => this.verbosity >= Verbosity.Normal;
public bool IsInfoEnabled => verbosity >= Verbosity.Normal;

// warnings are deliberately shown at quiet level
public bool IsWarnEnabled => this.verbosity >= Verbosity.Quiet;
public bool IsWarnEnabled => verbosity >= Verbosity.Quiet;

public bool Trace(string message) => this.IsTraceEnabled && Message(message);

Expand Down
2 changes: 1 addition & 1 deletion MinVerTests.Packages/SourceLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static async Task HasCommitSha()
int.Parse(Sdk.Version.Split(".")[0], NumberStyles.None, CultureInfo.InvariantCulture) < 8)
{
_ = await Sdk.DotNet(
$"add package Microsoft.SourceLink.GitHub --version 1.1.1 --package-directory packages", path);
"add package Microsoft.SourceLink.GitHub --version 1.1.1 --package-directory packages", path);
_ = await Sdk.DotNet("restore --packages packages", path);
}

Expand Down
10 changes: 4 additions & 6 deletions minver-cli/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ namespace MinVer;

internal sealed class Logger(Verbosity verbosity) : ILogger
{
private readonly Verbosity verbosity = verbosity;
public bool IsTraceEnabled => verbosity >= Verbosity.Trace;

public bool IsTraceEnabled => this.verbosity >= Verbosity.Trace;
public bool IsDebugEnabled => verbosity >= Verbosity.Debug;

public bool IsDebugEnabled => this.verbosity >= Verbosity.Debug;
public bool IsInfoEnabled => verbosity >= Verbosity.Info;

public bool IsInfoEnabled => this.verbosity >= Verbosity.Info;

public bool IsWarnEnabled => this.verbosity >= Verbosity.Warn;
public bool IsWarnEnabled => verbosity >= Verbosity.Warn;

public bool Trace(string message) => this.IsTraceEnabled && Message(message);

Expand Down
4 changes: 2 additions & 2 deletions targets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"test-lib",
"test the MinVer.Lib library",
DependsOn("build"),
() => RunAsync("dotnet", ["test", "./MinVerTests.Lib", "--framework", testFx, "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs]));
() => RunAsync("dotnet", ["test", "./MinVerTests.Lib", "--framework", testFx, "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs,]));

Target(
"test-packages",
"test the MinVer package and the minver-cli console app",
DependsOn("build"),
() => RunAsync("dotnet", ["test", "./MinVerTests.Packages", "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs]));
() => RunAsync("dotnet", ["test", "./MinVerTests.Packages", "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs,]));

Target(
"eyeball-minver-logs",
Expand Down

0 comments on commit 11c0e64

Please sign in to comment.