aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs5
-rw-r--r--crates/shirabe/src/repository/vcs/fossil_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs65
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs10
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs11
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs3
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs12
-rw-r--r--crates/shirabe/src/repository/vcs/vcs_driver.rs3
8 files changed, 52 insertions, 61 deletions
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 18f1cf1..4d66f37 100644
--- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs
+++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
@@ -5,7 +5,7 @@ use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode,
+ PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode,
};
use crate::cache::Cache;
@@ -17,7 +17,6 @@ use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
use crate::repository::vcs::VcsDriverBase;
-use crate::repository::vcs::VcsDriverInterface;
use crate::util::Forgejo;
use crate::util::ForgejoRepositoryData;
use crate::util::ForgejoUrl;
@@ -341,7 +340,7 @@ impl ForgejoDriver {
let composer = if self.inner.should_cache(identifier) {
if let Some(res) = self.inner.cache.as_mut().and_then(|c| c.read(identifier)) {
let parsed = JsonFile::parse_json(Some(res.as_str()), None)?;
- parsed.as_array().map(|m| m.clone())
+ parsed.as_array().cloned()
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let c = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs
index ebc0ac4..be3beff 100644
--- a/crates/shirabe/src/repository/vcs/fossil_driver.rs
+++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs
@@ -4,9 +4,7 @@ use crate::io::io_interface;
use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
-use shirabe_php_shim::{
- DATE_RFC3339, PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable,
-};
+use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable};
use crate::cache::Cache;
use crate::config::Config;
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index b5469ec..7a570bc 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -6,9 +6,9 @@ use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, InvalidArgumentException, LogicException, PhpMixed, RuntimeException,
- array_key_exists, array_search_mixed, extension_loaded, http_build_query_mixed, implode,
- in_array, is_array, sprintf, strpos,
+ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
+ array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array,
+ strpos,
};
use crate::cache::Cache;
@@ -257,9 +257,7 @@ impl GitBitbucketDriver {
if self.inner.should_cache(identifier) && {
let res = self.inner.cache.as_mut().and_then(|c| c.read(identifier));
if let Some(res) = res {
- composer = JsonFile::parse_json(Some(&res), None)?
- .as_array()
- .map(|m| m.clone());
+ composer = JsonFile::parse_json(Some(&res), None)?.as_array().cloned();
true
} else {
false
@@ -343,30 +341,35 @@ impl GitBitbucketDriver {
let support_entry = composer_map
.entry("support".to_string())
.or_insert(PhpMixed::Array(IndexMap::new()));
- if hash.is_none() {
- if let PhpMixed::Array(support_map) = support_entry {
- support_map.insert(
- "source".to_string(),
- PhpMixed::String(format!(
- "https://{}/{}/{}/src",
- self.inner.origin_url.clone(),
- self.owner.clone(),
- self.repository.clone(),
- )),
- );
+ match &hash {
+ None => {
+ if let PhpMixed::Array(support_map) = support_entry {
+ support_map.insert(
+ "source".to_string(),
+ PhpMixed::String(format!(
+ "https://{}/{}/{}/src",
+ self.inner.origin_url.clone(),
+ self.owner.clone(),
+ self.repository.clone(),
+ )),
+ );
+ }
+ }
+ Some(hash) => {
+ if let PhpMixed::Array(support_map) = support_entry {
+ support_map.insert(
+ "source".to_string(),
+ PhpMixed::String(format!(
+ "https://{}/{}/{}/src/{}/?at={}",
+ self.inner.origin_url.clone(),
+ self.owner.clone(),
+ self.repository.clone(),
+ hash,
+ label.clone(),
+ )),
+ );
+ }
}
- } else if let PhpMixed::Array(support_map) = support_entry {
- support_map.insert(
- "source".to_string(),
- PhpMixed::String(format!(
- "https://{}/{}/{}/src/{}/?at={}",
- self.inner.origin_url.clone(),
- self.owner.clone(),
- self.repository.clone(),
- hash.unwrap(),
- label.clone(),
- )),
- );
}
}
let support_has_issues = composer_map
@@ -432,7 +435,7 @@ impl GitBitbucketDriver {
self.owner.clone(),
self.repository.clone(),
identifier,
- file.to_string(),
+ file,
);
Ok(self
@@ -500,7 +503,7 @@ impl GitBitbucketDriver {
"https://bitbucket.org/{}/{}/get/{}.zip",
self.owner.clone(),
self.repository.clone(),
- identifier.to_string(),
+ identifier,
);
let mut m: IndexMap<String, String> = IndexMap::new();
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 7c50a7e..e45096d 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -6,10 +6,9 @@ use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, InvalidArgumentException, PhpMixed, RuntimeException, array_diff,
- array_key_exists, array_map, array_search_mixed, base64_decode, basename, count, empty,
- explode, extension_loaded, in_array, parse_url_all, sprintf, strpos, strtolower, substr, trim,
- urlencode,
+ InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map,
+ array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array,
+ parse_url_all, strpos, strtolower, substr, trim, urlencode,
};
use crate::cache::Cache;
@@ -21,7 +20,6 @@ use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
use crate::repository::vcs::VcsDriverBase;
-use crate::repository::vcs::VcsDriverInterface;
use crate::util::GitHub;
use crate::util::http::Response;
@@ -279,7 +277,7 @@ impl GitHubDriver {
.and_then(|c| c.read(identifier))
.unwrap_or_default();
let parsed = JsonFile::parse_json(Some(&res), None)?;
- parsed.as_array().map(|m| m.clone())
+ parsed.as_array().cloned()
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let composer = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index 7e8073d..a9a2fdb 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -6,9 +6,9 @@ use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, InvalidArgumentException, LogicException, PhpMixed, RuntimeException,
- array_search_mixed, array_shift, ctype_alnum, empty, explode, extension_loaded, implode,
- in_array, is_array, is_string, ord, sprintf, strpos, strtolower,
+ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
+ array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array,
+ is_string, ord, strpos, strtolower,
};
use crate::cache::Cache;
@@ -20,7 +20,6 @@ use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
use crate::repository::vcs::VcsDriverBase;
-use crate::repository::vcs::VcsDriverInterface;
use crate::util::GitLab;
use crate::util::HttpDownloader;
use crate::util::http::Response;
@@ -284,9 +283,7 @@ impl GitLabDriver {
.as_mut()
.and_then(|c| c.read(identifier))
.unwrap_or_default();
- JsonFile::parse_json(Some(&res), None)?
- .as_array()
- .map(|m| m.clone())
+ JsonFile::parse_json(Some(&res), None)?.as_array().cloned()
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let composer = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index 641e3e8..b668a2c 100644
--- a/crates/shirabe/src/repository/vcs/hg_driver.rs
+++ b/crates/shirabe/src/repository/vcs/hg_driver.rs
@@ -5,7 +5,6 @@ use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::io::io_interface;
use crate::repository::vcs::VcsDriverBase;
use crate::util::Filesystem;
use crate::util::Hg as HgUtils;
@@ -13,7 +12,7 @@ use crate::util::Url;
use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{DATE_RFC3339, PhpMixed, RuntimeException, dirname, is_dir, is_writable};
+use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable};
#[derive(Debug)]
pub struct HgDriver {
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index dd2d26d..087ed9d 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -5,8 +5,7 @@ use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- PhpMixed, RuntimeException, array_key_exists, is_array, sprintf, stripos, strrpos, strtr,
- substr, trim,
+ PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim,
};
use crate::cache::Cache;
@@ -187,8 +186,7 @@ impl SvnDriver {
}
let parsed = JsonFile::parse_json(Some(res.as_str()), None)?;
- let composer: Option<IndexMap<String, PhpMixed>> =
- parsed.as_array().map(|m| m.clone());
+ let composer: Option<IndexMap<String, PhpMixed>> = parsed.as_array().cloned();
self.inner
.info_cache
.insert(identifier.to_string(), composer.clone());
@@ -380,10 +378,10 @@ impl SvnDriver {
if self.branches.is_none() {
let mut branches: IndexMap<String, String> = IndexMap::new();
- let trunk_parent = if self.trunk_path.is_none() {
- format!("{}/", self.base_url)
+ let trunk_parent = if let Some(trunk_path) = self.trunk_path.as_ref() {
+ format!("{}/{}", self.base_url, trunk_path)
} else {
- format!("{}/{}", self.base_url, self.trunk_path.as_ref().unwrap())
+ format!("{}/", self.base_url)
};
let output = self.execute(
diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs
index 249e53f..5e0715c 100644
--- a/crates/shirabe/src/repository/vcs/vcs_driver.rs
+++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs
@@ -12,7 +12,6 @@ use crate::io::IOInterface;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::VcsDriverInterface;
-use crate::util::Filesystem;
use crate::util::HttpDownloader;
use crate::util::ProcessExecutor;
use crate::util::http::Response;
@@ -150,7 +149,7 @@ impl VcsDriverBase {
&& let Some(res) = self.cache.as_mut().and_then(|c| c.read(identifier))
{
let parsed = JsonFile::parse_json(Some(&res), None)?;
- let composer: Option<IndexMap<String, PhpMixed>> = parsed.as_array().map(|m| m.clone());
+ let composer: Option<IndexMap<String, PhpMixed>> = parsed.as_array().cloned();
self.info_cache
.insert(identifier.to_string(), composer.clone());
return Ok(Some(composer));