From 72b2e877c01e67ba7edd37e34ac2eadb7a1c62c4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 9 May 2026 19:59:58 +0900 Subject: refactor(vcs): mirror Composer interfaces; rename get_local_changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename `local_changes` → `get_local_changes` to match Composer's `getLocalChanges` - Add `is_change_report`, `is_vcs_capable_downloader`, `is_dvcs_downloader` trait methods to replace PHP `instanceof` checks - Add `VersionParser` stub to keep `VersionGuesser::new` signature compatible with Composer's constructor - Add `ArrayDumper` in status.rs mirroring `Composer\Package\Dumper\ArrayDumper`; expand `build_package_config` to include all fields that `VersionGuesser` inspects --- crates/mozart-vcs/src/downloader/git.rs | 14 +++++++++++++- crates/mozart-vcs/src/downloader/hg.rs | 14 +++++++++++++- crates/mozart-vcs/src/downloader/mod.rs | 11 ++++++++++- crates/mozart-vcs/src/downloader/svn.rs | 14 +++++++++++++- 4 files changed, 49 insertions(+), 4 deletions(-) (limited to 'crates/mozart-vcs/src/downloader') diff --git a/crates/mozart-vcs/src/downloader/git.rs b/crates/mozart-vcs/src/downloader/git.rs index 0c78f89..814d67e 100644 --- a/crates/mozart-vcs/src/downloader/git.rs +++ b/crates/mozart-vcs/src/downloader/git.rs @@ -96,7 +96,7 @@ impl VcsDownloader for GitDownloader { Ok(()) } - fn local_changes(&self, target: &Path) -> Result> { + fn get_local_changes(&self, target: &Path) -> Result> { if !target.join(".git").exists() { return Ok(None); } @@ -223,6 +223,18 @@ impl VcsDownloader for GitDownloader { )?; Ok(output.stdout) } + + fn is_change_report(&self) -> bool { + true + } + + fn is_vcs_capable_downloader(&self) -> bool { + true + } + + fn is_dvcs_downloader(&self) -> bool { + true + } } fn collect_show_ref(process: &ProcessExecutor, target: &Path) -> Result> { diff --git a/crates/mozart-vcs/src/downloader/hg.rs b/crates/mozart-vcs/src/downloader/hg.rs index 926cfa8..3230404 100644 --- a/crates/mozart-vcs/src/downloader/hg.rs +++ b/crates/mozart-vcs/src/downloader/hg.rs @@ -45,7 +45,7 @@ impl VcsDownloader for HgDownloader { Ok(()) } - fn local_changes(&self, target: &Path) -> Result> { + fn get_local_changes(&self, target: &Path) -> Result> { if !target.join(".hg").is_dir() { return Ok(None); } @@ -72,4 +72,16 @@ impl VcsDownloader for HgDownloader { )?; Ok(output.stdout) } + + fn is_change_report(&self) -> bool { + true + } + + fn is_vcs_capable_downloader(&self) -> bool { + true + } + + fn is_dvcs_downloader(&self) -> bool { + false + } } diff --git a/crates/mozart-vcs/src/downloader/mod.rs b/crates/mozart-vcs/src/downloader/mod.rs index 8948921..352f330 100644 --- a/crates/mozart-vcs/src/downloader/mod.rs +++ b/crates/mozart-vcs/src/downloader/mod.rs @@ -25,7 +25,7 @@ pub trait VcsDownloader { /// Detect local changes in the working copy. /// Returns `None` if clean, `Some(diff)` if modified. /// Mirrors `Composer\Downloader\ChangeReportInterface::getLocalChanges`. - fn local_changes(&self, target: &Path) -> Result>; + fn get_local_changes(&self, target: &Path) -> Result>; /// Detect commits present locally but not on the tracking remote. /// Returns `None` if there are no unpushed commits or the concept does @@ -44,4 +44,13 @@ pub trait VcsDownloader { /// Get commit log between two references. fn commit_logs(&self, from: &str, to: &str, target: &Path) -> Result; + + /// instanceof ChangeReportInterface + fn is_change_report(&self) -> bool; + + /// instanceof VcsCapableDownloaderInterface + fn is_vcs_capable_downloader(&self) -> bool; + + /// instanceof DvcsDownloaderInterface + fn is_dvcs_downloader(&self) -> bool; } diff --git a/crates/mozart-vcs/src/downloader/svn.rs b/crates/mozart-vcs/src/downloader/svn.rs index 533e15a..87b59da 100644 --- a/crates/mozart-vcs/src/downloader/svn.rs +++ b/crates/mozart-vcs/src/downloader/svn.rs @@ -51,7 +51,7 @@ impl VcsDownloader for SvnDownloader { Ok(()) } - fn local_changes(&self, target: &Path) -> Result> { + fn get_local_changes(&self, target: &Path) -> Result> { if !target.join(".svn").is_dir() { return Ok(None); } @@ -72,4 +72,16 @@ impl VcsDownloader for SvnDownloader { .execute(&["log", "-r", &range], Some(target))?; Ok(output.stdout) } + + fn is_change_report(&self) -> bool { + true + } + + fn is_vcs_capable_downloader(&self) -> bool { + true + } + + fn is_dvcs_downloader(&self) -> bool { + false + } } -- cgit v1.3.1