aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/hg.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-20 01:16:50 +0900
committernsfisis <nsfisis@gmail.com>2026-06-20 02:22:41 +0900
commitefec43b3b8827820cf35fe1b73d8e33f5fe84eb4 (patch)
treea62bbba72324de48be5f8e689559f8d9e288fc61 /crates/shirabe/src/util/hg.rs
parentcac18ef73a39b4ac41fa4d6ccb753804d4c42cb7 (diff)
downloadphp-shirabe-efec43b3b8827820cf35fe1b73d8e33f5fe84eb4.tar.gz
php-shirabe-efec43b3b8827820cf35fe1b73d8e33f5fe84eb4.tar.zst
php-shirabe-efec43b3b8827820cf35fe1b73d8e33f5fe84eb4.zip
refactor: auto-fix clippy warnings
Diffstat (limited to 'crates/shirabe/src/util/hg.rs')
-rw-r--r--crates/shirabe/src/util/hg.rs105
1 files changed, 51 insertions, 54 deletions
diff --git a/crates/shirabe/src/util/hg.rs b/crates/shirabe/src/util/hg.rs
index c8f5489..d20cf16 100644
--- a/crates/shirabe/src/util/hg.rs
+++ b/crates/shirabe/src/util/hg.rs
@@ -60,61 +60,59 @@ impl Hg {
&mut matches,
);
- if matched {
- if self
+ if matched
+ && self
.io
.has_authentication(matches.get("host").map(|s| s.as_str()).unwrap_or(""))
- {
- let authenticated_url = if matches.get("proto").map(|s| s.as_str()) == Some("ssh") {
- let user = if let Some(u) = matches.get("user") {
- format!("{}@", rawurlencode(u))
- } else {
- String::new()
- };
- format!(
- "{}://{}{}{}",
- matches.get("proto").unwrap_or(&String::new()),
- user,
- matches.get("host").unwrap_or(&String::new()),
- matches.get("path").unwrap_or(&String::new()),
- )
+ {
+ let authenticated_url = if matches.get("proto").map(|s| s.as_str()) == Some("ssh") {
+ let user = if let Some(u) = matches.get("user") {
+ format!("{}@", rawurlencode(u))
} else {
- let auth = self
- .io
- .get_authentication(matches.get("host").map(|s| s.as_str()).unwrap_or(""));
- format!(
- "{}://{}:{}@{}{}",
- matches.get("proto").unwrap_or(&String::new()),
- rawurlencode(
- auth.get("username")
- .and_then(|s| s.as_deref())
- .unwrap_or("")
- ),
- rawurlencode(
- auth.get("password")
- .and_then(|s| s.as_deref())
- .unwrap_or("")
- ),
- matches.get("host").unwrap_or(&String::new()),
- matches.get("path").unwrap_or(&String::new()),
- )
+ String::new()
};
+ format!(
+ "{}://{}{}{}",
+ matches.get("proto").unwrap_or(&String::new()),
+ user,
+ matches.get("host").unwrap_or(&String::new()),
+ matches.get("path").unwrap_or(&String::new()),
+ )
+ } else {
+ let auth = self
+ .io
+ .get_authentication(matches.get("host").map(|s| s.as_str()).unwrap_or(""));
+ format!(
+ "{}://{}:{}@{}{}",
+ matches.get("proto").unwrap_or(&String::new()),
+ rawurlencode(
+ auth.get("username")
+ .and_then(|s| s.as_deref())
+ .unwrap_or("")
+ ),
+ rawurlencode(
+ auth.get("password")
+ .and_then(|s| s.as_deref())
+ .unwrap_or("")
+ ),
+ matches.get("host").unwrap_or(&String::new()),
+ matches.get("path").unwrap_or(&String::new()),
+ )
+ };
- let command = command_callable(authenticated_url);
- let mut ignored_output = String::new();
- if self
- .process
- .borrow_mut()
- .execute_args(&command, &mut ignored_output, cwd)
- == 0
- {
- return Ok(());
- }
-
- let error = self.process.borrow().get_error_output().to_string();
- return self
- .throw_exception(&format!("Failed to clone {}, \n\n{}", url, error), &url);
+ let command = command_callable(authenticated_url);
+ let mut ignored_output = String::new();
+ if self
+ .process
+ .borrow_mut()
+ .execute_args(&command, &mut ignored_output, cwd)
+ == 0
+ {
+ return Ok(());
}
+
+ let error = self.process.borrow().get_error_output().to_string();
+ return self.throw_exception(&format!("Failed to clone {}, \n\n{}", url, error), &url);
}
let error = format!(
@@ -150,13 +148,12 @@ impl Hg {
&mut output,
(),
) == 0
- {
- if let Some(matches) = Preg::is_match_with_indexed_captures(
+ && let Some(matches) = Preg::is_match_with_indexed_captures(
r"/^.+? (\d+(?:\.\d+)+)(?:\+.*?)?\)?\r?\n/",
&output,
- ) {
- return matches.into_iter().nth(1);
- }
+ )
+ {
+ return matches.into_iter().nth(1);
}
None
})