diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-08 19:52:18 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-08 19:52:18 +0900 |
| commit | 5cb8fc4e306970764e84bb850da2c56f844c3b12 (patch) | |
| tree | 0d66f3129a26138fcfee9402616b24929c40a017 /crates/mozart-core/src/factory.rs | |
| parent | d83b9ef48775aeb31ba1909b29d5470e6d0ddaaa (diff) | |
| download | php-mozart-5cb8fc4e306970764e84bb850da2c56f844c3b12.tar.gz php-mozart-5cb8fc4e306970764e84bb850da2c56f844c3b12.tar.zst php-mozart-5cb8fc4e306970764e84bb850da2c56f844c3b12.zip | |
fix(status): align with Composer's StatusCommand pipeline
Replace the dist-hash tree-diff implementation with Composer's VCS-level
status flow: three buckets (errors / unpushed_changes / vcs_version_changes)
populated via ChangeReportInterface / DvcsDownloaderInterface /
VcsCapableDownloaderInterface, and a bitfield exit code (1|2|4) instead
of always 1.
Supporting work:
- mozart-semver: add normalize_branch (VersionParser::normalizeBranch).
- mozart-vcs: extend VcsDownloader trait with unpushed_changes /
vcs_reference; port GitDownloader::getUnpushedChanges (HEAD-ref
discovery + git diff --name-status remote...branch + two-pass fetch);
fix git status invocation to use --untracked-files=no (Composer parity);
add hasMetadataRepository preconditions to git/hg/svn local_changes;
port VersionGuesser (git/hg/svn dispatch — Fossil omitted, feature
branch detection runs sequentially instead of via async promises).
- mozart-core: extend LocalPackage with pretty_version, package_type,
installation_source, source, dist, extra; add InstallationSource and
PackageReference. factory.rs reads them from installed.json.
- mozart-registry: new download_manager mirroring
DownloadManager::getDownloaderForPackage.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-core/src/factory.rs')
| -rw-r--r-- | crates/mozart-core/src/factory.rs | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/crates/mozart-core/src/factory.rs b/crates/mozart-core/src/factory.rs index 92aa70e..c9d346b 100644 --- a/crates/mozart-core/src/factory.rs +++ b/crates/mozart-core/src/factory.rs @@ -276,15 +276,70 @@ fn read_local_packages(vendor_dir: &Path) -> anyhow::Result<Vec<LocalPackage>> { .and_then(|v| v.as_str()) .unwrap_or("") .to_string(); + let pretty_version = entry + .get("version") + .and_then(|v| v.as_str()) + .unwrap_or("") + .to_string(); let target_dir = entry .get("target-dir") .and_then(|v| v.as_str()) .map(|s| s.to_string()); - out.push(LocalPackage::new(pretty_name, target_dir)); + let package_type = entry + .get("type") + .and_then(|v| v.as_str()) + .map(|s| s.to_string()); + let installation_source = entry + .get("installation-source") + .and_then(|v| v.as_str()) + .and_then(crate::composer::InstallationSource::parse); + let source = read_package_reference(entry.get("source")); + let dist = read_package_reference(entry.get("dist")); + let extra = entry + .get("extra") + .cloned() + .unwrap_or(serde_json::Value::Null); + out.push(LocalPackage::new( + pretty_name, + pretty_version, + target_dir, + package_type, + installation_source, + source, + dist, + extra, + )); } Ok(out) } +fn read_package_reference( + value: Option<&serde_json::Value>, +) -> Option<crate::composer::PackageReference> { + let v = value?; + let kind = v.get("type").and_then(|x| x.as_str())?.to_string(); + let url = v + .get("url") + .and_then(|x| x.as_str()) + .unwrap_or("") + .to_string(); + let reference = v + .get("reference") + .and_then(|x| x.as_str()) + .map(|s| s.to_string()); + let shasum = v + .get("shasum") + .and_then(|x| x.as_str()) + .filter(|s| !s.is_empty()) + .map(|s| s.to_string()); + Some(crate::composer::PackageReference { + kind, + url, + reference, + shasum, + }) +} + #[cfg(test)] mod tests { use super::*; |
