GetUpdateableMods made and public for testing

This commit is contained in:
Canon
2026-03-12 06:54:31 +08:00
parent 08f467aaee
commit 0bd4151271
4 changed files with 8 additions and 8 deletions
+4 -3
View File
@@ -11,6 +11,9 @@ namespace FCPModUpdater.Commands;
[UsedImplicitly] [UsedImplicitly]
public class UpdateCommand : AsyncCommand<ModPathSettings> public class UpdateCommand : AsyncCommand<ModPathSettings>
{ {
public static IReadOnlyList<InstalledMod> GetUpdateableMods(IReadOnlyList<InstalledMod> mods)
=> mods.Where(m => m.Source == ModSource.Git && m.Status == ModStatus.Behind).ToList();
public override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings, public override async Task<int> ExecuteAsync(CommandContext context, ModPathSettings settings,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
@@ -41,9 +44,7 @@ public class UpdateCommand : AsyncCommand<ModPathSettings>
async () => await modDiscoveryService.DiscoverModsAsync(modsDirectory, ct: cancellationToken)); async () => await modDiscoveryService.DiscoverModsAsync(modsDirectory, ct: cancellationToken));
// Find updateable mods // Find updateable mods
var updateableMods = mods var updateableMods = GetUpdateableMods(mods);
.Where(m => m.Source == ModSource.Git && m.Status == ModStatus.Behind)
.ToList();
if (updateableMods.Count == 0) if (updateableMods.Count == 0)
{ {
+1 -1
View File
@@ -244,7 +244,7 @@ public partial class GitService : IGitService
} }
} }
private static IReadOnlyList<GitCommitInfo> ParseCommitLog(string output) internal static IReadOnlyList<GitCommitInfo> ParseCommitLog(string output)
{ {
var commits = new List<GitCommitInfo>(); var commits = new List<GitCommitInfo>();
var entries = output.Split("---", StringSplitOptions.RemoveEmptyEntries); var entries = output.Split("---", StringSplitOptions.RemoveEmptyEntries);
+2 -2
View File
@@ -171,7 +171,7 @@ public class ModDiscoveryService : IModDiscoveryService
/// <summary> /// <summary>
/// Tries to match a folder name to an org repo, accounting for GitHub ZIP download suffixes like -main, -master. /// Tries to match a folder name to an org repo, accounting for GitHub ZIP download suffixes like -main, -master.
/// </summary> /// </summary>
private static string? MatchRepoName(string folderName, HashSet<string> orgRepoNames) internal static string? MatchRepoName(string folderName, HashSet<string> orgRepoNames)
{ {
// Direct match // Direct match
if (orgRepoNames.Contains(folderName)) if (orgRepoNames.Contains(folderName))
@@ -191,7 +191,7 @@ public class ModDiscoveryService : IModDiscoveryService
return null; return null;
} }
private static ModStatus DetermineStatus(int behind, int ahead, bool hasLocalChanges, string? branch) internal static ModStatus DetermineStatus(int behind, int ahead, bool hasLocalChanges, string? branch)
{ {
if (branch == null) if (branch == null)
{ {
+1 -2
View File
@@ -29,7 +29,6 @@
"Spectre.Console": "0.53.1" "Spectre.Console": "0.53.1"
} }
} }
}, }
"net10.0/linux-x64": {}
} }
} }