From b1e9a21dc213942116664ff48cbd2c3c0f9781c9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 22 Aug 2023 18:26:35 -0400 Subject: [PATCH] Release Notes fixes - Do not use markdown with Nuget release notes. - Force asserts to evaluate as they were breaking the `TGSDeploy` notes --- .../Tgstation.Server.ReleaseNotes/Program.cs | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/tools/Tgstation.Server.ReleaseNotes/Program.cs b/tools/Tgstation.Server.ReleaseNotes/Program.cs index 978e5276bc..bc3ce94d6b 100644 --- a/tools/Tgstation.Server.ReleaseNotes/Program.cs +++ b/tools/Tgstation.Server.ReleaseNotes/Program.cs @@ -661,7 +661,7 @@ namespace Tgstation.Server.ReleaseNotes if (changelists.TryGetValue(component, out var currentChangelist)) currentChangelist.Changes.AddRange(tupleSelector); else - Debug.Assert(changelists.TryAdd(component, new Changelist + DebugAssert(changelists.TryAdd(component, new Changelist { Changes = tupleSelector.ToList(), Unreleased = false, @@ -725,7 +725,7 @@ namespace Tgstation.Server.ReleaseNotes await previousTask; - Debug.Assert(!(await needExtendedComponentVersions) || changelists.Where(x => x.Key == Component.Core).All(x => x.Value.ComponentVersions != null && x.Value.ComponentVersions.Count > 3)); + DebugAssert(!(await needExtendedComponentVersions) || changelists.Where(x => x.Key == Component.Core).All(x => x.Value.ComponentVersions != null && x.Value.ComponentVersions.Count > 3)); return Tuple.Create(changelists.ToDictionary(kvp => kvp.Key, kvp => kvp.Value), await componentVersions, isReleasePR); } @@ -987,7 +987,7 @@ The user account that created this pull request is available to correct any issu newList = newList.OrderBy(x => x).ToList(); var index = newList.IndexOf(componentVersion); - Debug.Assert(index != -1); + DebugAssert(index != -1); if (index != (newList.Count - 1)) { componentVersion = newList[index + 1]; @@ -1013,10 +1013,10 @@ The user account that created this pull request is available to correct any issu entry.Changes.AddRange(changelist.Changes); } - Debug.Assert(list.Select(x => x.Version.ToString()).Distinct().Count() == list.Count); + DebugAssert(list.Select(x => x.Version.ToString()).Distinct().Count() == list.Count); if (component == Component.Core) { - Debug.Assert(list.All(x => x.Version == milestoneVersion)); + DebugAssert(list.All(x => x.Version == milestoneVersion)); } list = list.OrderByDescending(x => x.Version).ToList(); @@ -1038,7 +1038,7 @@ The user account that created this pull request is available to correct any issu }); } else - Debug.Assert(finalResults[Component.Core].All(x => x.Version == milestoneVersion && x.ComponentVersions != null && x.ComponentVersions.Count > 3)); + DebugAssert(finalResults[Component.Core].All(x => x.Version == milestoneVersion && x.ComponentVersions != null && x.ComponentVersions.Count > 3)); var notes = new ReleaseNotes { @@ -1189,7 +1189,7 @@ The user account that created this pull request is available to correct any issu .Where(x => x.Key == Component.Core) .ToList(); - Debug.Assert( + DebugAssert( coreCls.Count == milestonesToProcess.Count); var distinctCoreVersions = coreCls @@ -1204,7 +1204,7 @@ The user account that created this pull request is available to correct any issu .Where(x => !distinctCoreVersions.Any(y => Version.Parse(x.Title.AsSpan(1)) == y)) .ToList(); - Debug.Assert(missingCoreVersions.Count == 0); + DebugAssert(missingCoreVersions.Count == 0); var changelistsGroupedByComponent = milestonePRTasks @@ -1236,7 +1236,7 @@ The user account that created this pull request is available to correct any issu .ToList())) }; - Debug.Assert(releaseNotes.Components.ContainsKey(Component.Core) && releaseNotes.Components[Component.Core].Count == milestonesToProcess.Count); + DebugAssert(releaseNotes.Components.ContainsKey(Component.Core) && releaseNotes.Components[Component.Core].Count == milestonesToProcess.Count); if (previousNotes != null) { @@ -1274,7 +1274,7 @@ The user account that created this pull request is available to correct any issu foreach (var kvp in releaseNotes.Components) { var distinctCount = kvp.Value.Select(changelist => changelist.Version.ToString()).Distinct().Count(); - Debug.Assert(distinctCount == kvp.Value.Count); + DebugAssert(distinctCount == kvp.Value.Count); foreach (var cl in kvp.Value) { @@ -1313,11 +1313,14 @@ The user account that created this pull request is available to correct any issu throw new Exception($"Changlist {changelist.Version} has no changes!"); } - static string GenerateComponentNotes(ReleaseNotes releaseNotes, Component component, Version version) + static string GenerateComponentNotes(ReleaseNotes releaseNotes, Component component, Version version, bool useMarkdown) { var relevantChangelog = releaseNotes.Components[component].FirstOrDefault(x => x.Version == version); - var newNotes = new StringBuilder("Full changelog can be found [here](https://raw.githubusercontent.com/tgstation/tgstation-server/gh-pages/changelog.yml)."); + var newNotes = new StringBuilder( + useMarkdown + ? "Full changelog can be found [here](https://raw.githubusercontent.com/tgstation/tgstation-server/gh-pages/changelog.yml)." + : "Full changelog can be found here: https://raw.githubusercontent.com/tgstation/tgstation-server/gh-pages/changelog.yml."); if (relevantChangelog != null) { newNotes.AppendLine(); @@ -1331,7 +1334,7 @@ The user account that created this pull request is available to correct any issu static async Task ReleaseComponent(IGitHubClient client, Version version, Component component) { var releaseNotes = await GenerateNotes(client, new Dictionary { { component, version } }); - await File.WriteAllTextAsync(OutputPath, GenerateComponentNotes(releaseNotes, component, version)); + await File.WriteAllTextAsync(OutputPath, GenerateComponentNotes(releaseNotes, component, version, true)); return 0; } @@ -1373,7 +1376,7 @@ The user account that created this pull request is available to correct any issu var component = kvp.Key; var csprojPath = CsprojSubstitution.Replace("$PROJECT$", kvp.Value); - var markdown = GenerateComponentNotes(releaseNotes, component, componentVersions[component]); + var markdown = GenerateComponentNotes(releaseNotes, component, componentVersions[component], false); var escapedMarkdown = SecurityElement.Escape(markdown); @@ -1557,5 +1560,15 @@ package (version) distribution(s); urgency=urgency await File.WriteAllTextAsync(outputPath, changelog); return 0; } + + static void DebugAssert(bool condition, string message = null) + { + // This exists because one of the fucking asserts evaluates an enumerable or something and it was getting optimized out in release + // I CBA to track this down. + if (message != null) + Debug.Assert(condition, message); + else + Debug.Assert(condition); + } } }