aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs/perforce_driver.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
commita1c7e6908a26e10f6e1f23a51721664b5e2d838d (patch)
treec575c76f1b43359ed74913da4c6a2636643f1ba0 /crates/shirabe/src/repository/vcs/perforce_driver.rs
parent7f606f36fef0c0467c3c0db3d0da33af486dae8a (diff)
downloadphp-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.gz
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.zst
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.zip
chore(style): cargo fmt
Diffstat (limited to 'crates/shirabe/src/repository/vcs/perforce_driver.rs')
-rw-r--r--crates/shirabe/src/repository/vcs/perforce_driver.rs66
1 files changed, 55 insertions, 11 deletions
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<Option<String>> {
- 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<Option<chrono::DateTime<chrono::Utc>>> {
+ pub fn get_change_date(
+ &self,
+ _identifier: &str,
+ ) -> anyhow::Result<Option<chrono::DateTime<chrono::Utc>>> {
Ok(None)
}
@@ -89,9 +115,22 @@ impl PerforceDriver {
pub fn get_source(&self, identifier: &str) -> IndexMap<String, PhpMixed> {
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<Response> {
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 {