add simple generate changelog feature
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
|
||||
internal class GenerateChangelogFeature : PluginFunction, IPluginFeatureProvider<GenerateChangelogFeature>
|
||||
{
|
||||
public static GenerateChangelogFeature Instance { get; } = new();
|
||||
|
||||
public GenerateChangelogFeature() : base(FeatureTypes.Tools, "origin.genchangelog", FeatureNamesLangRes.GenerateChangelogFeature)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.time_machine, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurActionSet is not UpdateInfo updateInfos)
|
||||
return null;
|
||||
|
||||
var changelog = SharedFunctions.GenerateChangelog(p.Api.CurWorkspace.InstallInfos, updateInfos);
|
||||
if (!string.IsNullOrWhiteSpace(changelog))
|
||||
{
|
||||
Clipboard.SetText(changelog);
|
||||
RadMessageBox.Show(p.Api.MainWindow, MsgBoxLangRes.ChangelogCopiedToClipboard, MsgBoxLangRes.ChangelogCopiedToClipboard_Title, MessageBoxButtons.OK, RadMessageIcon.Info);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,15 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Generate changelog ähnelt.
|
||||
/// </summary>
|
||||
internal static string GenerateChangelogFeature {
|
||||
get {
|
||||
return ResourceManager.GetString("GenerateChangelogFeature", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die GitLab workspace ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -129,6 +129,9 @@
|
||||
<data name="ClearDirectLinksFeature" xml:space="preserve">
|
||||
<value>Clear direct links</value>
|
||||
</data>
|
||||
<data name="GenerateChangelogFeature" xml:space="preserve">
|
||||
<value>Generate changelog</value>
|
||||
</data>
|
||||
<data name="GitLabWorkspace" xml:space="preserve">
|
||||
<value>GitLab workspace</value>
|
||||
</data>
|
||||
|
||||
@@ -60,6 +60,24 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die The changelog for the selected version has been generated and copied to the clipboard. ähnelt.
|
||||
/// </summary>
|
||||
internal static string ChangelogCopiedToClipboard {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangelogCopiedToClipboard", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Changelog generated successfully ähnelt.
|
||||
/// </summary>
|
||||
internal static string ChangelogCopiedToClipboard_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangelogCopiedToClipboard_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Are you sure that you want to delete this update? ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -117,6 +117,12 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ChangelogCopiedToClipboard" xml:space="preserve">
|
||||
<value>The changelog for the selected version has been generated and copied to the clipboard.</value>
|
||||
</data>
|
||||
<data name="ChangelogCopiedToClipboard_Title" xml:space="preserve">
|
||||
<value>Changelog generated successfully</value>
|
||||
</data>
|
||||
<data name="RemoveUpdate" xml:space="preserve">
|
||||
<value>Are you sure that you want to delete this update?</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user