Skip to content

Commit

Permalink
Fix version summary when finalizing a changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrofigo committed Sep 5, 2023
1 parent 459430a commit 0994b8b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/Nuke.Common/ChangeLog/ChangeLogTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ internal static IEnumerable<ReleaseSection> GetReleaseSections(List<string> cont
{
static bool IsReleaseHead(string str)
=> str.StartsWith("## ");

static bool IsVersionSummary(string str)
=> str.StartsWith("[");

static string GetCaption(string str)
=> str
Expand All @@ -206,7 +209,7 @@ static string GetCaption(string str)
}

var caption = GetCaption(line);
var nextReleaseHeadIndex = content.FindIndex(index + 1, IsReleaseHead);
var nextReleaseHeadIndex = content.FindIndex(index + 1, s => IsReleaseHead(s) || IsVersionSummary(s));

var releaseData =
new ReleaseSection
Expand Down Expand Up @@ -235,7 +238,6 @@ private static void UpdateVersionSummary(string tag, List<string> content, [CanB

content.RemoveRange(lastSection.EndIndex + 1, content.Count - lastSection.EndIndex - 1);

content.Add(string.Empty);
content.Add($"[{firstSection.Caption}]: {repository.GetGitHubCompareTagToHeadUrl(tag)}");
for (var i = 1; i + 1 < sections.Count; i++)
content.Add($"[{sections[i].Caption}]: {repository.GetGitHubCompareTagsUrl(sections[i].Caption, sections[i + 1].Caption)}");
Expand Down

0 comments on commit 0994b8b

Please sign in to comment.