From f26e1a6ed8057ce8784565010fd4103b4e0ae5c9 Mon Sep 17 00:00:00 2001 From: Sora Date: Wed, 18 Dec 2024 21:05:09 +0100 Subject: [PATCH] Some dev tests --- SA-Mod-Manager/App.xaml.cs | 13 ++++++++++--- SA-Mod-Manager/GamesInstall.cs | 6 +++++- SA-Mod-Manager/Updater/GitHub.cs | 13 ++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/SA-Mod-Manager/App.xaml.cs b/SA-Mod-Manager/App.xaml.cs index ca6bd99d..7803e37e 100644 --- a/SA-Mod-Manager/App.xaml.cs +++ b/SA-Mod-Manager/App.xaml.cs @@ -302,12 +302,13 @@ private async Task InitUriAsync(string[] args, bool alreadyRunning) } - public static async Task<(bool, WorkflowRunInfo, GitHubArtifact)> GetArtifact() + public static async Task<(bool, WorkflowRunInfo, GitHubArtifact, string)> GetArtifact() { + Debugger.Launch(); var workflowRun = await GitHub.GetLatestWorkflowRun(); if (workflowRun is null) - return (false, null, null); + return (false, null, null, null); bool hasUpdate = RepoCommit != workflowRun.HeadSHA; @@ -331,7 +332,7 @@ private async Task InitUriAsync(string[] args, bool alreadyRunning) } } - return (hasUpdate, workflowRun, info); + return (hasUpdate, workflowRun, info, "Changelog are currently not available for dev version.\n"); } public static async Task PerformDevUpdateManagerCheck() @@ -340,6 +341,12 @@ public static async Task PerformDevUpdateManagerCheck() var update = await App.GetArtifact(); if (update.Item2 is not null) { + string changelog = await GitHub.GetGitChangeLog(update.Item4); + var manager = new InfoManagerUpdate(changelog, "Dev"); + manager.ShowDialog(); + + if (manager.DialogResult != true) + return false; Logger.Log("Now Installing Latest Dev Build Update ..."); diff --git a/SA-Mod-Manager/GamesInstall.cs b/SA-Mod-Manager/GamesInstall.cs index 66d6f51b..bb679e13 100644 --- a/SA-Mod-Manager/GamesInstall.cs +++ b/SA-Mod-Manager/GamesInstall.cs @@ -155,8 +155,12 @@ public static async Task InstallDLL_Loader(Game game, bool isupdate = false) } } + + } + else + { + ((MainWindow)App.Current.MainWindow)?.UpdateManagerStatusText("Error Install Loader: " + response.StatusCode); } - //offline version if (!File.Exists(loaderPath)) diff --git a/SA-Mod-Manager/Updater/GitHub.cs b/SA-Mod-Manager/Updater/GitHub.cs index d60e71a4..e0f1b5c3 100644 --- a/SA-Mod-Manager/Updater/GitHub.cs +++ b/SA-Mod-Manager/Updater/GitHub.cs @@ -312,12 +312,12 @@ public static async Task GetLatestAction() if (actions != null && actions.Actions.Count > 0) { - return actions.Actions[0]; // The first workflow run in the list is the most recent one + return actions.Actions[0]; //The first workflow run in the list is the most recent one } } - Console.WriteLine($"Error: {response.StatusCode}"); + ((MainWindow)App.Current.MainWindow)?.UpdateManagerStatusText("Error GitHub Action: " + response.StatusCode); return null; } @@ -341,8 +341,11 @@ public static async Task> GetArtifactsForAction(long action return artifacts.Artifacts; // The first workflow run in the list is the most recent one } } + else + { + ((MainWindow)App.Current.MainWindow)?.UpdateManagerStatusText("Error Artifacts: " + response.StatusCode); + } - Console.WriteLine($"Error: {response.StatusCode}"); return null; } @@ -365,7 +368,7 @@ public static async Task GetLatestWorkflowRun() { for (int i = 0; i < apiResponse.Runs.Count; i++) { - if (apiResponse.Runs[i].HeadBranch.ToLower() == branch.ToLower()) //only get builds from the current branch. + if (apiResponse.Runs[i].HeadBranch.Equals(branch, StringComparison.CurrentCultureIgnoreCase)) //only get builds from the current branch. { return apiResponse.Runs[i]; //return the first build that contains the right branch, this should be the last update every time. } @@ -373,7 +376,7 @@ public static async Task GetLatestWorkflowRun() } } - Console.WriteLine($"Error: {response.StatusCode}"); + ((MainWindow)App.Current.MainWindow)?.UpdateManagerStatusText("Error WorkFlow: " + response.StatusCode); return null; }