add simple generate changelog feature

This commit is contained in:
2024-10-13 09:22:19 +02:00
parent ee69d8af56
commit 8561fdb09b
6 changed files with 116 additions and 1 deletions

View File

@@ -1,7 +1,9 @@
using ModpackUpdater.Apps.Manager.Api.Model;
using Microsoft.Extensions.Primitives;
using ModpackUpdater.Apps.Manager.Api.Model;
using ModpackUpdater.Apps.Manager.Ui;
using ModpackUpdater.Manager;
using Pilz.UI.Extensions;
using System.Text;
using Telerik.WinControls.UI;
namespace ModpackUpdater.Apps.Manager.Features;
@@ -154,4 +156,50 @@ internal static class SharedFunctions
gridView?.EndUpdate();
rwb?.StopWaiting();
}
public static string GenerateChangelog(InstallInfos installInfos, UpdateInfo updateInfos)
{
var log = new StringBuilder();
foreach (var action in updateInfos.Actions.OrderBy(n => n.Type))
{
// Create copy
var copy = new UpdateAction();
ModpackInstaller.DuplicateTo(action, copy);
// Resolve inherit
if (!string.IsNullOrWhiteSpace(copy.InheritFrom))
ModpackInstaller.ResolveInherit(copy, installInfos);
if (string.IsNullOrWhiteSpace(copy.Name) || copy.Type != UpdateActionType.Update)
continue;
// Append bullet
log.Append('-');
// Append action indicator
log.Append(' ');
log.Append("⚒️");
// Append name
log.Append(' ');
log.Append("**");
log.Append(copy.Name);
log.Append("**");
// Append new version
if (!string.IsNullOrWhiteSpace(copy.SourceTag))
{
log.Append(' ');
log.Append('`');
log.Append(copy.SourceTag);
log.Append('`');
}
// Append new line
log.AppendLine();
}
return log.ToString().TrimEnd();
}
}