diff options
Diffstat (limited to 'crates/shirabe/src/downloader/hg_downloader.rs')
| -rw-r--r-- | crates/shirabe/src/downloader/hg_downloader.rs | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/crates/shirabe/src/downloader/hg_downloader.rs b/crates/shirabe/src/downloader/hg_downloader.rs index 7a48054..c5a65a0 100644 --- a/crates/shirabe/src/downloader/hg_downloader.rs +++ b/crates/shirabe/src/downloader/hg_downloader.rs @@ -1,7 +1,9 @@ //! ref: composer/src/Composer/Downloader/HgDownloader.php use crate::config::Config; +use crate::downloader::ChangeReportInterface; use crate::downloader::DownloaderInterface; +use crate::downloader::VcsCapableDownloaderInterface; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; @@ -152,31 +154,6 @@ impl HgDownloader { Ok(None) } - pub fn get_local_changes( - &self, - package: PackageInterfaceHandle, - path: String, - ) -> Option<String> { - if !std::path::Path::new(&format!("{}/.hg", path)).is_dir() { - return None; - } - - let mut output = String::new(); - self.inner.process.borrow_mut().execute_args( - &["hg".to_string(), "st".to_string()], - &mut output, - shirabe_php_shim::realpath(&path), - ); - - let output = output.trim().to_string(); - - if !output.is_empty() { - Some(output) - } else { - None - } - } - pub(crate) fn get_commit_logs( &self, from_reference: String, @@ -218,11 +195,54 @@ impl HgDownloader { } } +impl ChangeReportInterface for HgDownloader { + fn get_local_changes( + &self, + _package: PackageInterfaceHandle, + path: &str, + ) -> Result<Option<String>> { + if !std::path::Path::new(&format!("{}/.hg", path)).is_dir() { + return Ok(None); + } + + let mut output = String::new(); + self.inner.process.borrow_mut().execute_args( + &["hg".to_string(), "st".to_string()], + &mut output, + shirabe_php_shim::realpath(path), + ); + + let output = output.trim().to_string(); + + Ok(if !output.is_empty() { + Some(output) + } else { + None + }) + } +} + +impl VcsCapableDownloaderInterface for HgDownloader { + fn get_vcs_reference(&self, package: PackageInterfaceHandle, path: String) -> Option<String> { + self.inner.get_vcs_reference(package, &path) + } +} + // TODO(phase-b): wire up VcsDownloader trait properly. HgDownloader extends VcsDownloader which // implements DownloaderInterface in PHP. Delegating each trait method to todo!() until the inner // VcsDownloaderBase exposes the matching impl surface. #[async_trait::async_trait(?Send)] impl DownloaderInterface for HgDownloader { + fn as_change_report_interface(&self) -> Option<&dyn crate::downloader::ChangeReportInterface> { + Some(self) + } + + fn as_vcs_capable_downloader_interface( + &self, + ) -> Option<&dyn crate::downloader::VcsCapableDownloaderInterface> { + Some(self) + } + fn get_installation_source(&self) -> String { todo!() } |
