From a1c7e6908a26e10f6e1f23a51721664b5e2d838d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 17 May 2026 02:53:53 +0900 Subject: chore(style): cargo fmt --- .../shirabe/src/repository/vcs/perforce_driver.rs | 66 ++++++++++++++++++---- 1 file changed, 55 insertions(+), 11 deletions(-) (limited to 'crates/shirabe/src/repository/vcs/perforce_driver.rs') diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs index f32f895..cd3b32b 100644 --- a/crates/shirabe/src/repository/vcs/perforce_driver.rs +++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs @@ -22,12 +22,20 @@ pub struct PerforceDriver { impl PerforceDriver { pub fn initialize(&mut self) -> anyhow::Result<()> { - self.depot = self.inner.repo_config.get("depot") + self.depot = self + .inner + .repo_config + .get("depot") .and_then(|v| v.as_string()) .unwrap_or("") .to_string(); self.branch = String::new(); - if let Some(branch) = self.inner.repo_config.get("branch").and_then(|v| v.as_string()) { + if let Some(branch) = self + .inner + .repo_config + .get("branch") + .and_then(|v| v.as_string()) + { if !branch.is_empty() { self.branch = branch.to_string(); } @@ -48,7 +56,13 @@ impl PerforceDriver { return Ok(()); } - let cache_vcs_dir = self.inner.config.get("cache-vcs-dir").as_string().unwrap_or("").to_string(); + let cache_vcs_dir = self + .inner + .config + .get("cache-vcs-dir") + .as_string() + .unwrap_or("") + .to_string(); if !Cache::is_usable(&cache_vcs_dir) { return Err(RuntimeException { message: "PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled".to_string(), @@ -57,16 +71,28 @@ impl PerforceDriver { } let repo_dir = format!("{}/{}", cache_vcs_dir, self.depot); - self.perforce = Some(Perforce::create(repo_config, &self.inner.url, &repo_dir, &self.inner.process, self.inner.io.as_ref())?); + self.perforce = Some(Perforce::create( + repo_config, + &self.inner.url, + &repo_dir, + &self.inner.process, + self.inner.io.as_ref(), + )?); Ok(()) } pub fn get_file_content(&self, file: &str, identifier: &str) -> anyhow::Result> { - self.perforce.as_ref().unwrap().get_file_content(file, identifier) + self.perforce + .as_ref() + .unwrap() + .get_file_content(file, identifier) } - pub fn get_change_date(&self, _identifier: &str) -> anyhow::Result>> { + pub fn get_change_date( + &self, + _identifier: &str, + ) -> anyhow::Result>> { Ok(None) } @@ -89,9 +115,22 @@ impl PerforceDriver { pub fn get_source(&self, identifier: &str) -> IndexMap { let mut source = IndexMap::new(); source.insert("type".to_string(), PhpMixed::String("perforce".to_string())); - source.insert("url".to_string(), self.inner.repo_config.get("url").cloned().unwrap_or(PhpMixed::Null)); - source.insert("reference".to_string(), PhpMixed::String(identifier.to_string())); - source.insert("p4user".to_string(), PhpMixed::String(self.perforce.as_ref().unwrap().get_user().to_string())); + source.insert( + "url".to_string(), + self.inner + .repo_config + .get("url") + .cloned() + .unwrap_or(PhpMixed::Null), + ); + source.insert( + "reference".to_string(), + PhpMixed::String(identifier.to_string()), + ); + source.insert( + "p4user".to_string(), + PhpMixed::String(self.perforce.as_ref().unwrap().get_user().to_string()), + ); source } @@ -101,14 +140,19 @@ impl PerforceDriver { pub fn has_composer_file(&self, identifier: &str) -> bool { let path = format!("//{}/{}", self.depot, identifier); - self.perforce.as_ref().unwrap().get_composer_information(&path).map_or(false, |info| !info.is_empty()) + self.perforce + .as_ref() + .unwrap() + .get_composer_information(&path) + .map_or(false, |info| !info.is_empty()) } pub fn get_contents(&self, _url: &str) -> anyhow::Result { Err(BadMethodCallException { message: "Not implemented/used in PerforceDriver".to_string(), code: 0, - }.into()) + } + .into()) } pub fn supports(io: &dyn IOInterface, config: &Config, url: &str, deep: bool) -> bool { -- cgit v1.3.1