fix: label plugins that aren't actively being tested "available" in the installer

This commit is contained in:
goat 2022-10-30 11:41:07 +01:00
parent 53211c0a7b
commit 46cb6a3b74
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 37 additions and 12 deletions

View file

@ -205,6 +205,25 @@ Thanks and have fun!";
return !manifest.IsHide;
}
/// <summary>
/// Check if a manifest even has an available testing version.
/// </summary>
/// <param name="manifest">The manifest to test.</param>
/// <returns>Whether or not a testing version is available.</returns>
public static bool HasTestingVersion(PluginManifest manifest)
{
var av = manifest.AssemblyVersion;
var tv = manifest.TestingAssemblyVersion;
var hasTv = tv != null;
if (hasTv)
{
return tv > av;
}
return false;
}
/// <summary>
/// Print to chat any plugin updates and whether they were successful.
/// </summary>
@ -249,6 +268,16 @@ Thanks and have fun!";
}
}
/// <summary>
/// For a given manifest, determine if the user opted into testing this plugin.
/// </summary>
/// <param name="manifest">Manifest to check.</param>
/// <returns>A value indicating whether testing should be used.</returns>
public bool HasTestingOptIn(PluginManifest manifest)
{
return this.configuration.PluginTestingOptIns!.Any(x => x.InternalName == manifest.InternalName);
}
/// <summary>
/// For a given manifest, determine if the testing version should be used over the normal version.
/// The higher of the two versions is calculated after checking other settings.
@ -260,22 +289,13 @@ Thanks and have fun!";
if (!this.configuration.DoPluginTest)
return false;
if (this.configuration.PluginTestingOptIns!.All(x => x.InternalName != manifest.InternalName))
if (!this.HasTestingOptIn(manifest))
return false;
if (manifest.IsTestingExclusive)
return true;
var av = manifest.AssemblyVersion;
var tv = manifest.TestingAssemblyVersion;
var hasTv = tv != null;
if (hasTv)
{
return tv > av;
}
return false;
return HasTestingVersion(manifest);
}
/// <inheritdoc/>