forked from 1b-agent/opencadstudio-upstream
Merge remote-tracking branch 'origin/main' into plugin/host-model-api
# Conflicts: # crates/ocs_plugin_api/src/process/v4.rs # src/app/update/mod.rs
This commit is contained in:
commit
8648225ac5
309 files changed
+81166
-4157
No files matched your search
+24
-15
@@ -84,19 +84,11 @@ impl ExternalPlugin {
|
||||
|
||||
/// Returns whether the package's dependency fingerprint matches the host.
|
||||
pub fn acadrust_compatible(&self) -> bool {
|
||||
if !ocs_plugin_api::version_info::uses_acadrust_gate(self.api_version) {
|
||||
return true;
|
||||
}
|
||||
if !self.acadrust_declared {
|
||||
return true;
|
||||
}
|
||||
match self.acadrust_source.as_deref() {
|
||||
None | Some("") => false,
|
||||
Some(source) => ocs_plugin_api::version_info::acadrust_sources_compatible(
|
||||
source,
|
||||
ocs_plugin_api::version_info::host_acadrust_source(),
|
||||
),
|
||||
}
|
||||
acadrust_source_compatible(
|
||||
self.api_version,
|
||||
self.acadrust_declared,
|
||||
self.acadrust_source.as_deref(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns whether the package's rustc matches the host.
|
||||
@@ -123,6 +115,22 @@ impl ExternalPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn acadrust_source_compatible(
|
||||
api_version: u32,
|
||||
declared: bool,
|
||||
source: Option<&str>,
|
||||
) -> bool {
|
||||
!ocs_plugin_api::version_info::uses_acadrust_gate(api_version)
|
||||
|| declared
|
||||
&& source.is_some_and(|source| {
|
||||
!source.is_empty()
|
||||
&& ocs_plugin_api::version_info::acadrust_sources_compatible(
|
||||
source,
|
||||
ocs_plugin_api::version_info::host_acadrust_source(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// `<config>/OpenCADStudio/plugins`, matching the settings/recent-files store.
|
||||
/// Overridable via `OCS_PLUGINS_DIR` for tests.
|
||||
pub fn plugins_dir() -> Option<PathBuf> {
|
||||
@@ -718,7 +726,7 @@ rustc_version = "rustc 0.0.0-fake"
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn undeclared_acadrust_falls_back_to_api_gate() {
|
||||
fn undeclared_acadrust_is_incompatible_for_gated_api() {
|
||||
let toml = r#"
|
||||
[plugin]
|
||||
id = "opencad.test"
|
||||
@@ -729,7 +737,8 @@ api_version = 4
|
||||
let p = parse_plugin_toml(toml).expect("parsed");
|
||||
assert!(!p.acadrust_declared);
|
||||
assert!(p.acadrust_source.is_none());
|
||||
assert!(p.acadrust_compatible(), "undeclared acadrust is treated as compatible");
|
||||
assert!(!p.acadrust_compatible());
|
||||
assert!(!p.loadable());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -221,21 +221,11 @@ pub fn fetch_release_info(repo: &str) -> Result<Vec<ReleaseInfo>, String> {
|
||||
.ok_or_else(|| format!("release {} plugin.toml is missing an id", release.tag))?;
|
||||
let acadrust_source = manifest.acadrust_source.clone();
|
||||
let acadrust_declared = manifest.acadrust_declared;
|
||||
let acadrust_compatible = if !ocs_plugin_api::version_info::uses_acadrust_gate(
|
||||
let acadrust_compatible = external::acadrust_source_compatible(
|
||||
manifest.api_version,
|
||||
) {
|
||||
true
|
||||
} else if !acadrust_declared {
|
||||
true
|
||||
} else {
|
||||
match acadrust_source.as_deref() {
|
||||
None | Some("") => false,
|
||||
Some(source) => ocs_plugin_api::version_info::acadrust_sources_compatible(
|
||||
source,
|
||||
ocs_plugin_api::version_info::host_acadrust_source(),
|
||||
),
|
||||
}
|
||||
};
|
||||
acadrust_declared,
|
||||
acadrust_source.as_deref(),
|
||||
);
|
||||
let rustc_version = manifest.rustc_version.clone();
|
||||
let rustc_declared = manifest.rustc_declared;
|
||||
let rustc_compatible = if !ocs_plugin_api::version_info::uses_acadrust_gate(
|
||||
@@ -268,17 +258,6 @@ pub fn fetch_release_info(repo: &str) -> Result<Vec<ReleaseInfo>, String> {
|
||||
}
|
||||
}
|
||||
|
||||
// Once a repo declares a fingerprint, require it on later API versions.
|
||||
let any_acadrust_declared = info.iter().any(|r| r.acadrust_declared);
|
||||
if any_acadrust_declared {
|
||||
for r in &mut info {
|
||||
if !r.acadrust_declared
|
||||
&& ocs_plugin_api::version_info::uses_acadrust_gate(r.api_version)
|
||||
{
|
||||
r.acadrust_compatible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if info.is_empty() {
|
||||
Err(last_error.unwrap_or_else(|| "no installable releases found".to_string()))
|
||||
} else {
|
||||
@@ -350,18 +329,12 @@ pub fn install(release: &Release, repository: &str) -> Result<String, String> {
|
||||
));
|
||||
}
|
||||
|
||||
if ocs_plugin_api::version_info::uses_acadrust_gate(manifest.api_version)
|
||||
&& manifest.acadrust_declared
|
||||
{
|
||||
if ocs_plugin_api::version_info::uses_acadrust_gate(manifest.api_version) {
|
||||
let Some(source) = manifest.acadrust_source.as_deref() else {
|
||||
return Err(
|
||||
"Release declares acadrust metadata but has no source; cannot verify ABI compatibility".to_string(),
|
||||
);
|
||||
return Err("Release has no acadrust source; cannot verify ABI compatibility".to_string());
|
||||
};
|
||||
if source.is_empty() {
|
||||
return Err(
|
||||
"Release declares acadrust metadata but has no source; cannot verify ABI compatibility".to_string(),
|
||||
);
|
||||
return Err("Release has no acadrust source; cannot verify ABI compatibility".to_string());
|
||||
}
|
||||
if !ocs_plugin_api::version_info::acadrust_sources_compatible(
|
||||
source,
|
||||
|
||||
Reference in new issue
Block a user