aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader/hg_downloader.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/downloader/hg_downloader.rs')
-rw-r--r--crates/shirabe/src/downloader/hg_downloader.rs61
1 files changed, 48 insertions, 13 deletions
diff --git a/crates/shirabe/src/downloader/hg_downloader.rs b/crates/shirabe/src/downloader/hg_downloader.rs
index 7501fb6..ff06806 100644
--- a/crates/shirabe/src/downloader/hg_downloader.rs
+++ b/crates/shirabe/src/downloader/hg_downloader.rs
@@ -1,11 +1,11 @@
//! ref: composer/src/Composer/Downloader/HgDownloader.php
-use anyhow::Result;
-use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;
-use shirabe_php_shim::RuntimeException;
use crate::downloader::vcs_downloader::VcsDownloader;
use crate::package::package_interface::PackageInterface;
use crate::util::hg::Hg as HgUtils;
+use anyhow::Result;
+use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;
+use shirabe_php_shim::RuntimeException;
#[derive(Debug)]
pub struct HgDownloader {
@@ -24,7 +24,8 @@ impl HgDownloader {
return Err(RuntimeException {
message: "hg was not found in your PATH, skipping source download".to_string(),
code: 0,
- }.into());
+ }
+ .into());
}
Ok(shirabe_external_packages::react::promise::resolve(None))
@@ -40,7 +41,13 @@ impl HgDownloader {
let path_clone = path.clone();
let clone_command = move |url: String| -> Vec<String> {
- vec!["hg".to_string(), "clone".to_string(), "--".to_string(), url, path_clone.clone()]
+ vec![
+ "hg".to_string(),
+ "clone".to_string(),
+ "--".to_string(),
+ url,
+ path_clone.clone(),
+ ]
};
hg_utils.run_command(clone_command, url, Some(path.clone()));
@@ -51,7 +58,12 @@ impl HgDownloader {
package.get_source_reference().unwrap_or_default(),
];
let mut ignored_output = String::new();
- if self.inner.process.execute(&command, &mut ignored_output, shirabe_php_shim::realpath(&path)) != 0 {
+ if self.inner.process.execute(
+ &command,
+ &mut ignored_output,
+ shirabe_php_shim::realpath(&path),
+ ) != 0
+ {
return Err(RuntimeException {
message: format!(
"Failed to execute {}\n\n{}",
@@ -59,7 +71,8 @@ impl HgDownloader {
self.inner.process.get_error_output()
),
code: 0,
- }.into());
+ }
+ .into());
}
Ok(shirabe_external_packages::react::promise::resolve(None))
@@ -75,7 +88,10 @@ impl HgDownloader {
let hg_utils = HgUtils::new(&self.inner.io, &self.inner.config, &self.inner.process);
let ref_ = target.get_source_reference().unwrap_or_default();
- self.inner.io.write_error(&format!(" Updating to {}", target.get_source_reference().unwrap_or_default()));
+ self.inner.io.write_error(&format!(
+ " Updating to {}",
+ target.get_source_reference().unwrap_or_default()
+ ));
if !self.has_metadata_repository(path.clone()) {
return Err(RuntimeException {
@@ -94,14 +110,23 @@ impl HgDownloader {
let ref_clone = ref_.clone();
let up_command = move |_url: String| -> Vec<String> {
- vec!["hg".to_string(), "up".to_string(), "--".to_string(), ref_clone.clone()]
+ vec![
+ "hg".to_string(),
+ "up".to_string(),
+ "--".to_string(),
+ ref_clone.clone(),
+ ]
};
hg_utils.run_command(up_command, url, Some(path));
Ok(shirabe_external_packages::react::promise::resolve(None))
}
- pub fn get_local_changes(&self, package: &dyn PackageInterface, path: String) -> Option<String> {
+ pub fn get_local_changes(
+ &self,
+ package: &dyn PackageInterface,
+ path: String,
+ ) -> Option<String> {
if !std::path::Path::new(&format!("{}/.hg", path)).is_dir() {
return None;
}
@@ -115,7 +140,11 @@ impl HgDownloader {
let output = output.trim().to_string();
- if !output.is_empty() { Some(output) } else { None }
+ if !output.is_empty() {
+ Some(output)
+ } else {
+ None
+ }
}
pub(crate) fn get_commit_logs(
@@ -134,7 +163,12 @@ impl HgDownloader {
];
let mut output = String::new();
- if self.inner.process.execute(&command, &mut output, shirabe_php_shim::realpath(&path)) != 0 {
+ if self
+ .inner
+ .process
+ .execute(&command, &mut output, shirabe_php_shim::realpath(&path))
+ != 0
+ {
return Err(RuntimeException {
message: format!(
"Failed to execute {}\n\n{}",
@@ -142,7 +176,8 @@ impl HgDownloader {
self.inner.process.get_error_output()
),
code: 0,
- }.into());
+ }
+ .into());
}
Ok(output)