diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-10 20:31:00 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-10 20:31:00 +0900 |
| commit | 59bab6efee41a196b0d9d392167c536abbe068ba (patch) | |
| tree | f36ca1c8534cf703b357d3f9090ba85efd9a9b74 /crates/mozart-core/src/downloader/vcs_downloader.rs | |
| parent | 24bb31c109332ae982b7091ffcd5183442ce6f6f (diff) | |
| download | php-mozart-59bab6efee41a196b0d9d392167c536abbe068ba.tar.gz php-mozart-59bab6efee41a196b0d9d392167c536abbe068ba.tar.zst php-mozart-59bab6efee41a196b0d9d392167c536abbe068ba.zip | |
refactor(downloader): introduce top-level downloader module
Move VCS downloaders and DownloadManager out of vcs/repository into a
new top-level downloader module mirroring Composer\Downloader, and add
stub types for the remaining Composer downloader hierarchy (file,
archive variants, path, perforce, fossil, exceptions, interfaces) so
future ports have a home.
Diffstat (limited to 'crates/mozart-core/src/downloader/vcs_downloader.rs')
| -rw-r--r-- | crates/mozart-core/src/downloader/vcs_downloader.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/crates/mozart-core/src/downloader/vcs_downloader.rs b/crates/mozart-core/src/downloader/vcs_downloader.rs new file mode 100644 index 0000000..ce56d41 --- /dev/null +++ b/crates/mozart-core/src/downloader/vcs_downloader.rs @@ -0,0 +1,55 @@ +/// The VCS downloader interface. +/// +/// Corresponds to Composer's `VcsDownloader` hierarchy. +pub trait VcsDownloader { + /// Prepare for installation (e.g., sync mirror cache). + fn download(&self, url: &str, reference: &str, target: &std::path::Path) -> anyhow::Result<()>; + + /// Install (clone/checkout) the source to the target directory. + fn install(&self, url: &str, reference: &str, target: &std::path::Path) -> anyhow::Result<()>; + + /// Update the source at target to a new reference. + fn update( + &self, + url: &str, + old_ref: &str, + new_ref: &str, + target: &std::path::Path, + ) -> anyhow::Result<()>; + + /// Remove the source from the target directory. + fn remove(&self, target: &std::path::Path) -> anyhow::Result<()>; + + /// Detect local changes in the working copy. + /// Returns `None` if clean, `Some(diff)` if modified. + /// Mirrors `Composer\Downloader\ChangeReportInterface::getLocalChanges`. + fn get_local_changes(&self, target: &std::path::Path) -> anyhow::Result<Option<String>>; + + /// Detect commits present locally but not on the tracking remote. + /// Returns `None` if there are no unpushed commits or the concept does + /// not apply (only `GitDownloader` implements this in Composer's + /// `DvcsDownloaderInterface`). + fn unpushed_changes(&self, _target: &std::path::Path) -> anyhow::Result<Option<String>> { + Ok(None) + } + + /// Resolve the working copy's current VCS reference (e.g. commit hash). + /// Returns `None` if no reference can be determined. Mirrors + /// `Composer\Downloader\VcsCapableDownloaderInterface::getVcsReference`. + fn vcs_reference(&self, _target: &std::path::Path) -> anyhow::Result<Option<String>> { + Ok(None) + } + + /// Get commit log between two references. + fn commit_logs(&self, from: &str, to: &str, target: &std::path::Path) + -> anyhow::Result<String>; + + /// 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; +} |
