Skip to content

Commit

Permalink
Improved detection for mostly larger version tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Oct 27, 2023
1 parent f1e0d0f commit 0365801
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions RelaxVersioner.Core/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#nullable enable

using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -89,19 +90,16 @@ internal static class Analyzer
break;
}

var found = false;
foreach (var tag in commit.Tags)
{
if (Version.TryParse(tag.Name, out var v2))
{
version = v2;
reached.Add(commit, version);
found = true;
break;
}
}
if (found)
// Detected mostly larger version tag.
var candidates = commit.Tags.
Select(tag => Version.TryParse(tag.Name, out var v) ? v : null!).
Where(v => v != null).
OrderByDescending(v => v).
ToArray();
if (candidates.Length >= 1)
{
version = candidates[0];
reached.Add(commit, version);
break;
}

Expand Down

0 comments on commit 0365801

Please sign in to comment.