Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit 54cfeb1

Browse files
committed
Add more null checks for github config
1 parent e5212fd commit 54cfeb1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

PluginLoader/Data/GitHubPlugin.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public override bool LoadData(ref PluginDataConfig config, bool enabled)
4747
{
4848
if (enabled)
4949
{
50-
if (config is GitHubPluginConfig githubConfig &&
51-
(string.IsNullOrWhiteSpace(githubConfig.SelectedVersion) || AlternateVersions.Any(x => x.Name.Equals(githubConfig.SelectedVersion, StringComparison.OrdinalIgnoreCase))))
50+
if (config is GitHubPluginConfig githubConfig && IsValidConfig(githubConfig))
5251
{
5352
this.config = githubConfig;
5453
return false;
@@ -71,6 +70,15 @@ public override bool LoadData(ref PluginDataConfig config, bool enabled)
7170
return false;
7271
}
7372

73+
private bool IsValidConfig(GitHubPluginConfig githubConfig)
74+
{
75+
if (string.IsNullOrWhiteSpace(githubConfig.SelectedVersion))
76+
return true;
77+
if (AlternateVersions == null)
78+
return false;
79+
return AlternateVersions.Any(x => x.Name.Equals(githubConfig.SelectedVersion, StringComparison.OrdinalIgnoreCase));
80+
}
81+
7482
public void InitPaths()
7583
{
7684
string[] nameArgs = Id.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
@@ -147,7 +155,7 @@ public override Assembly GetAssembly()
147155

148156
private string GetSelectedCommit()
149157
{
150-
if (string.IsNullOrWhiteSpace(config.SelectedVersion))
158+
if (config == null || string.IsNullOrWhiteSpace(config.SelectedVersion) || AlternateVersions == null)
151159
return Commit;
152160
Branch branch = AlternateVersions.FirstOrDefault(x => x.Name.Equals(config.SelectedVersion, StringComparison.OrdinalIgnoreCase));
153161
if (branch == null)

0 commit comments

Comments
 (0)