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/version_guesser.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'crates/mozart-vcs/src/version_guesser.rs') diff --git a/crates/mozart-vcs/src/version_guesser.rs b/crates/mozart-vcs/src/version_guesser.rs index e70eb4e..038e332 100644 --- a/crates/mozart-vcs/src/version_guesser.rs +++ b/crates/mozart-vcs/src/version_guesser.rs @@ -20,6 +20,25 @@ use crate::process::ProcessExecutor; const DEFAULT_BRANCH_ALIAS: &str = "9999999-dev"; +/// Mirrors `Composer\Package\Version\VersionParser` (itself a thin wrapper +/// around `Composer\Semver\VersionParser`). In Rust, semver parsing is +/// handled by `mozart_semver` directly, so this type carries no state; +/// it exists to keep `VersionGuesser::new` signature compatible with the +/// PHP constructor. +pub struct VersionParser; + +impl Default for VersionParser { + fn default() -> Self { + Self::new() + } +} + +impl VersionParser { + pub fn new() -> Self { + Self + } +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct GuessedVersion { pub version: String, @@ -35,12 +54,15 @@ pub struct VersionGuesser { impl Default for VersionGuesser { fn default() -> Self { - Self::new() + Self::new(VersionParser::new()) } } impl VersionGuesser { - pub fn new() -> Self { + /// Mirrors `Composer\Package\Version\VersionGuesser::__construct`. + /// `_version_parser` is accepted for API parity but unused — Rust relies + /// on `mozart_semver` directly. + pub fn new(_version_parser: VersionParser) -> Self { Self { process: ProcessExecutor::new(), } -- cgit v1.3.1