From efec43b3b8827820cf35fe1b73d8e33f5fe84eb4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 20 Jun 2026 01:16:50 +0900 Subject: refactor: auto-fix clippy warnings --- crates/shirabe/src/util/hg.rs | 105 ++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 54 deletions(-) (limited to 'crates/shirabe/src/util/hg.rs') 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 }) -- cgit v1.3.1