diff --git a/src/common/fs.rs b/src/common/fs.rs index f40d959..5b592d4 100644 --- a/src/common/fs.rs +++ b/src/common/fs.rs @@ -1,10 +1,10 @@ use crate::prelude::*; use remove_dir_all::remove_dir_all; +use std::env::current_exe; use std::ffi::OsStr; -use std::fs::{create_dir_all, File, read_link}; +use std::fs::{create_dir_all, read_link, File}; use std::io::BufReader; use thiserror::Error; -use std::env::current_exe; pub trait ToStringExt { fn to_string(&self) -> String; @@ -43,13 +43,12 @@ pub fn open>(filename: P) -> Result { pub fn read_lines>(filename: P) -> Result>> { let file = open(filename.as_ref())?; - Ok(BufReader::new(file) - .lines() - .map(|line| line.map_err(Error::from))) + Ok(BufReader::new(file).lines().map(|line| line.map_err(Error::from))) } fn pathbuf_to_string>(pathbuf: P) -> Result { - Ok(pathbuf.as_ref() + Ok(pathbuf + .as_ref() .as_os_str() .to_str() .ok_or_else(|| InvalidPath(pathbuf.as_ref().to_path_buf())) diff --git a/src/common/git.rs b/src/common/git.rs index 3ed2dde..6780952 100644 --- a/src/common/git.rs +++ b/src/common/git.rs @@ -22,11 +22,10 @@ pub fn meta(uri: &str) -> (String, String, String) { } else { // Users can pass name starting wirh a slash let first_char = uri.chars().next(); - + if first_char == Some('/') { format!("https://github.com{uri}") - } - else { + } else { format!("https://github.com/{uri}") } } @@ -70,7 +69,7 @@ mod tests { assert_eq!(user, "user".to_string()); assert_eq!(repo, "repo".to_string()); } - + #[test] fn test_meta_github_repo_name() { let (actual_uri, user, repo) = meta("user/repo"); @@ -78,7 +77,7 @@ mod tests { assert_eq!(user, "user".to_string()); assert_eq!(repo, "repo".to_string()); } - + #[test] fn test_meta_github_repo_name_with_slash() { let (actual_uri, user, repo) = meta("/user/repo"); @@ -86,7 +85,7 @@ mod tests { assert_eq!(user, "user".to_string()); assert_eq!(repo, "repo".to_string()); } - + #[test] fn test_meta_github_clean_link() { let (actual_uri, user, repo) = meta("github.com/user/repo"); @@ -94,7 +93,7 @@ mod tests { assert_eq!(user, "user".to_string()); assert_eq!(repo, "repo".to_string()); } - + #[test] fn test_meta_random_git_provider_http() { let (actual_uri, user, repo) = meta("https://sr.ht/user/repo");