diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-17 02:53:53 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-17 02:53:53 +0900 |
| commit | a1c7e6908a26e10f6e1f23a51721664b5e2d838d (patch) | |
| tree | c575c76f1b43359ed74913da4c6a2636643f1ba0 /crates/shirabe/src/util/composer_mirror.rs | |
| parent | 7f606f36fef0c0467c3c0db3d0da33af486dae8a (diff) | |
| download | php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.gz php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.zst php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.zip | |
chore(style): cargo fmt
Diffstat (limited to 'crates/shirabe/src/util/composer_mirror.rs')
| -rw-r--r-- | crates/shirabe/src/util/composer_mirror.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/shirabe/src/util/composer_mirror.rs b/crates/shirabe/src/util/composer_mirror.rs index 1ec3e56..0743e9f 100644 --- a/crates/shirabe/src/util/composer_mirror.rs +++ b/crates/shirabe/src/util/composer_mirror.rs @@ -39,7 +39,10 @@ impl ComposerMirror { to.push(pv); } - let url = from.iter().zip(to.iter()).fold(mirror_url.to_string(), |acc, (f, t)| acc.replace(f, t)); + let url = from + .iter() + .zip(to.iter()) + .fold(mirror_url.to_string(), |acc, (f, t)| acc.replace(f, t)); assert!(!url.is_empty()); url } @@ -50,9 +53,14 @@ impl ComposerMirror { url: &str, r#type: Option<&str>, ) -> String { - let normalized_url = if let Some(m) = Preg::match_(r"^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$", url) { + let normalized_url = if let Some(m) = Preg::match_( + r"^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$", + url, + ) { format!("gh-{}/{}", m[1], m[2]) - } else if let Some(m) = Preg::match_(r"^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$", url) { + } else if let Some(m) = + Preg::match_(r"^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$", url) + { format!("bb-{}/{}", m[1], m[2]) } else { Preg::replace(r"[^a-z0-9_.-]", "-", url.trim_matches('/')) @@ -64,12 +72,7 @@ impl ComposerMirror { .fold(mirror_url.to_string(), |acc, (f, t)| acc.replace(f, t)) } - pub fn process_hg_url( - mirror_url: &str, - package_name: &str, - url: &str, - r#type: &str, - ) -> String { + pub fn process_hg_url(mirror_url: &str, package_name: &str, url: &str, r#type: &str) -> String { Self::process_git_url(mirror_url, package_name, url, Some(r#type)) } } |
