Skip to content

Commit

Permalink
Some dev tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora-yx committed Dec 18, 2024
1 parent fa9b933 commit f26e1a6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
13 changes: 10 additions & 3 deletions SA-Mod-Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<bool> PerformDevUpdateManagerCheck()
Expand All @@ -340,6 +341,12 @@ public static async Task<bool> 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 ...");

Expand Down
6 changes: 5 additions & 1 deletion SA-Mod-Manager/GamesInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
13 changes: 8 additions & 5 deletions SA-Mod-Manager/Updater/GitHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ public static async Task<GitHubAction> 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;

}
Expand All @@ -341,8 +341,11 @@ public static async Task<List<GitHubArtifact>> 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;

}
Expand All @@ -365,15 +368,15 @@ public static async Task<WorkflowRunInfo> 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.
}
}
}
}

Console.WriteLine($"Error: {response.StatusCode}");
((MainWindow)App.Current.MainWindow)?.UpdateManagerStatusText("Error WorkFlow: " + response.StatusCode);
return null;

}
Expand Down

0 comments on commit f26e1a6

Please sign in to comment.