diff options
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/gitlab_driver.rs | 39 |
2 files changed, 13 insertions, 32 deletions
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 6b62d818..8fe93018 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -18,8 +18,8 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists, - array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array_strict, - is_array, php_regex, strpos, + array_search_mixed, extension_loaded, http_build_query_mixed, implode, is_array, php_regex, + strpos, }; #[derive(Debug)] @@ -697,7 +697,7 @@ impl GitBitbucketDriver { { let te = &e; let code = te.get_code(); - let in_set = in_array_strict(code, &[PhpMixed::Int(403), PhpMixed::Int(404)]); + let in_set = matches!(code, 403 | 404); if in_set || (401 == code && strpos(te.get_message(), "Could not authenticate against") diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index 8f49e8ef..5fe513f6 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -18,8 +18,8 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed, - array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array_loose, - in_array_strict, is_array, is_string, ord, php_regex, strpos, strtolower, + array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array_loose, is_array, + is_string, ord, php_regex, strpos, strtolower, }; /// Driver for GitLab API, use the Git driver for local checkouts. @@ -115,13 +115,7 @@ impl GitLabDriver { .get(&CaptureKey::ByName("scheme".to_string())) .cloned() .unwrap_or_default(); - self.scheme = if in_array_strict( - scheme_match.clone(), - &[ - PhpMixed::String("https".to_string()), - PhpMixed::String("http".to_string()), - ], - ) { + self.scheme = if matches!(scheme_match.as_str(), "https" | "http") { scheme_match } else if self .inner @@ -158,14 +152,7 @@ impl GitLabDriver { .filter(|_| is_string(&protocol_value)) { // https treated as a synonym for http. - if !in_array_strict( - protocol.to_string(), - &[ - PhpMixed::String("git".to_string()), - PhpMixed::String("http".to_string()), - PhpMixed::String("https".to_string()), - ], - ) { + if !matches!(protocol, "git" | "http" | "https") { return Err(RuntimeException { message: "gitlab-protocol must be one of git, http.".to_string(), code: 0, @@ -601,18 +588,12 @@ impl GitLabDriver { let bytes: Vec<char> = string.chars().collect(); for byte in &bytes { let character = byte.to_string(); - let final_character = if !ctype_alnum(&character) - && !in_array_strict( - character.clone(), - &[ - PhpMixed::String("-".to_string()), - PhpMixed::String("_".to_string()), - ], - ) { - format!("%{:02X}", ord(&character)) - } else { - character - }; + let final_character = + if !ctype_alnum(&character) && !matches!(character.as_str(), "-" | "_") { + format!("%{:02X}", ord(&character)) + } else { + character + }; encoded.push_str(&final_character); } |
