aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-php-shim/src/url.rs10
-rw-r--r--crates/shirabe/src/installer/installation_manager.rs2
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs62
-rw-r--r--crates/shirabe/src/util/gitlab.rs26
4 files changed, 24 insertions, 76 deletions
diff --git a/crates/shirabe-php-shim/src/url.rs b/crates/shirabe-php-shim/src/url.rs
index 27463ce0..c2ac725d 100644
--- a/crates/shirabe-php-shim/src/url.rs
+++ b/crates/shirabe-php-shim/src/url.rs
@@ -95,14 +95,8 @@ pub fn http_build_query_mixed(
encode_pairs(&pairs, arg_separator)
}
-pub fn http_build_query(
- data: &[(&str, &str)],
- numeric_prefix: &str,
- arg_separator: &str,
-) -> String {
- // numeric_prefix only applies to integer keys, which a string-keyed slice never has.
- let _ = numeric_prefix;
- encode_pairs(data, arg_separator)
+pub fn http_build_query(data: &[(&str, &str)]) -> String {
+ encode_pairs(data, "&")
}
fn encode_pairs<T: serde::Serialize>(pairs: T, arg_separator: &str) -> String {
diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs
index 2d21fb54..a9e66ccb 100644
--- a/crates/shirabe/src/installer/installation_manager.rs
+++ b/crates/shirabe/src/installer/installation_manager.rs
@@ -867,7 +867,7 @@ impl InstallationManager {
.collect();
http.insert(
"content".to_string(),
- PhpMixed::String(http_build_query(&params_vec, "", "&")),
+ PhpMixed::String(http_build_query(&params_vec)),
);
http.insert("timeout".to_string(), PhpMixed::Int(3));
opts.insert(
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index eb64c4f8..c3da08ff 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -19,8 +19,7 @@ use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
- array_search_mixed, extension_loaded, http_build_query_mixed, implode, is_array, php_regex,
- strpos,
+ array_search_mixed, extension_loaded, http_build_query, implode, is_array, php_regex, strpos,
};
#[derive(Debug)]
@@ -152,18 +151,7 @@ impl GitBitbucketDriver {
"https://api.bitbucket.org/2.0/repositories/{}/{}?{}",
self.owner.clone(),
self.repository.clone(),
- http_build_query_mixed(
- &{
- let mut m: IndexMap<String, PhpMixed> = IndexMap::new();
- m.insert(
- "fields".to_string(),
- PhpMixed::String("-project,-owner".to_string()),
- );
- m
- },
- "",
- "&",
- ),
+ http_build_query(&[("fields", "-project,-owner")]),
);
let repo_data = self
@@ -524,23 +512,11 @@ impl GitBitbucketDriver {
let mut resource = format!(
"{}?{}",
self.tags_url.clone(),
- http_build_query_mixed(
- &{
- let mut m: IndexMap<String, PhpMixed> = IndexMap::new();
- m.insert("pagelen".to_string(), PhpMixed::Int(100));
- m.insert(
- "fields".to_string(),
- PhpMixed::String("values.name,values.target.hash,next".to_string()),
- );
- m.insert(
- "sort".to_string(),
- PhpMixed::String("-target.date".to_string()),
- );
- m
- },
- "",
- "&",
- ),
+ http_build_query(&[
+ ("pagelen", "100"),
+ ("fields", "values.name,values.target.hash,next"),
+ ("sort", "-target.date"),
+ ]),
);
let mut has_next = true;
while has_next {
@@ -603,25 +579,11 @@ impl GitBitbucketDriver {
let mut resource = format!(
"{}?{}",
self.branches_url.clone(),
- http_build_query_mixed(
- &{
- let mut m: IndexMap<String, PhpMixed> = IndexMap::new();
- m.insert("pagelen".to_string(), PhpMixed::Int(100));
- m.insert(
- "fields".to_string(),
- PhpMixed::String(
- "values.name,values.target.hash,values.heads,next".to_string(),
- ),
- );
- m.insert(
- "sort".to_string(),
- PhpMixed::String("-target.date".to_string()),
- );
- m
- },
- "",
- "&",
- ),
+ http_build_query(&[
+ ("pagelen", "100"),
+ ("fields", "values.name,values.target.hash,values.heads,next"),
+ ("sort", "-target.date"),
+ ]),
);
let mut has_next = true;
while has_next {
diff --git a/crates/shirabe/src/util/gitlab.rs b/crates/shirabe/src/util/gitlab.rs
index 73806762..3d1fb2be 100644
--- a/crates/shirabe/src/util/gitlab.rs
+++ b/crates/shirabe/src/util/gitlab.rs
@@ -425,15 +425,11 @@ impl GitLab {
let headers = vec!["Content-Type: application/x-www-form-urlencoded".to_string()];
let api_url = origin_url;
- let data = http_build_query(
- &[
- ("username", username.as_str()),
- ("password", password.as_str()),
- ("grant_type", "password"),
- ],
- "",
- "&",
- );
+ let data = http_build_query(&[
+ ("username", username.as_str()),
+ ("password", password.as_str()),
+ ("grant_type", "password"),
+ ]);
let mut http_inner: IndexMap<String, PhpMixed> = IndexMap::new();
http_inner.insert("method".to_string(), PhpMixed::String("POST".to_string()));
http_inner.insert(
@@ -498,14 +494,10 @@ impl GitLab {
let headers = vec!["Content-Type: application/x-www-form-urlencoded".to_string()];
- let data = http_build_query(
- &[
- ("refresh_token", refresh_token.as_str()),
- ("grant_type", "refresh_token"),
- ],
- "",
- "&",
- );
+ let data = http_build_query(&[
+ ("refresh_token", refresh_token.as_str()),
+ ("grant_type", "refresh_token"),
+ ]);
let mut http_inner = IndexMap::new();
http_inner.insert("method".to_string(), PhpMixed::String("POST".to_string()));
http_inner.insert(