Skip to content

Commit

Permalink
Merge pull request #450 from rasmus/fix-semver-alignment
Browse files Browse the repository at this point in the history
Better guess at a version
  • Loading branch information
rasmus authored Dec 8, 2024
2 parents 8c76ae1 + 88f444a commit e0cb1a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 0.31-beta

* *Nothing yet...*
* Fix: If we have no exact match, we should try to find one that matches regardless of metadata

# 0.30-beta

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public void SetUp()
"1.0.129",
"1.1,1.0-alpha,0.9",
"1.0-alpha")]
[TestCase(
"1.0.0-alpha",
"1.1.0,1.0.0,0.9.0",
"1.0.0")]
public async Task PickExpectedVersion(
string version,
string releaseNoteVersions,
Expand Down
18 changes: 17 additions & 1 deletion Source/Bake/Cooking/Ingredients/Gathers/ReleaseNotesGather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ private async Task InternalGatherAsync(
.Where(n => n.Version.IsSubset(version))
.OrderByDescending(n => n.Version)
.ToList();

if (withSubset.Any())
{
var notes = withSubset.First();
Expand All @@ -147,6 +146,23 @@ private async Task InternalGatherAsync(
return notes;
}

var withLegacyVersion = releaseNotes
.Where(n => n.Version.LegacyVersion == version.LegacyVersion)
.OrderByDescending(n => n.Version)
.ToList();
if (withLegacyVersion.Any())
{
var notes = withLegacyVersion.First();

_logger.LogInformation(
"Found {Count} release notes that matches the non-meta {Version}, picking the most recent. Got {PickedVersion}",
withLegacyVersion.Count,
version.ToString(),
notes.Version.ToString());

return notes;
}

var orderedReleaseNotes = releaseNotes
.OrderByDescending(n => n.Version)
.ToList();
Expand Down

0 comments on commit e0cb1a6

Please sign in to comment.