Skip to content

Commit d906eb5

Browse files
committed
feat(plugins): Don’t treat invalid VersionReq as a mismatch
1 parent e920bf2 commit d906eb5

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/plugins/registry.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ fn get_plugin_matching_version(
337337
for plugin_version in plugin_versions {
338338
let plugin_version_version = Version::parse(&plugin_version.version)?;
339339

340-
if check_plugin_version_usability(plugin_version)
340+
if check_plugin_version_usability(plugin_version)?
341341
&& &plugin_version_version
342342
> plugin_latest_version
343343
.as_ref()
@@ -351,32 +351,29 @@ fn get_plugin_matching_version(
351351
} else if let Some(plugin_version) = plugin_versions
352352
.iter()
353353
.find(|v| v.version == requested_version)
354-
&& check_plugin_version_usability(plugin_version)
354+
&& check_plugin_version_usability(plugin_version)?
355355
{
356356
return Ok(Some(Version::parse(&plugin_version.version)?));
357357
}
358358

359359
Ok(None)
360360
}
361361

362-
fn check_plugin_version_usability(plugin_version: &RegistryPluginVersion) -> bool {
362+
fn check_plugin_version_usability(plugin_version: &RegistryPluginVersion) -> Result<bool> {
363363
if let Some(deprecated) = plugin_version.deprecated
364364
&& deprecated
365365
{
366-
return false;
366+
return Ok(false);
367367
}
368368

369-
let Ok(plugin_compatible_program_version) =
370-
VersionReq::parse(&plugin_version.compatible_program_version)
371-
else {
372-
return false;
373-
};
369+
let plugin_compatible_program_version =
370+
VersionReq::parse(&plugin_version.compatible_program_version)?;
374371

375372
if !plugin_compatible_program_version.matches(&PROGRAM_VERSION) {
376-
return false;
373+
return Ok(false);
377374
}
378375

379-
true
376+
Ok(true)
380377
}
381378

382379
async fn fetch_registry(

0 commit comments

Comments
 (0)