aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/repository')
-rw-r--r--crates/shirabe/src/repository/array_repository.rs9
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs28
-rw-r--r--crates/shirabe/src/repository/filesystem_repository.rs6
-rw-r--r--crates/shirabe/src/repository/filter_repository.rs4
-rw-r--r--crates/shirabe/src/repository/package_repository.rs1
-rw-r--r--crates/shirabe/src/repository/path_repository.rs4
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs171
-rw-r--r--crates/shirabe/src/repository/repository_factory.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs2
-rw-r--r--crates/shirabe/src/repository/vcs/fossil_driver.rs10
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs11
-rw-r--r--crates/shirabe/src/repository/vcs/git_driver.rs26
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs46
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs17
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs16
-rw-r--r--crates/shirabe/src/repository/vcs/perforce_driver.rs2
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs26
-rw-r--r--crates/shirabe/src/repository/vcs/vcs_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs_repository.rs8
19 files changed, 133 insertions, 262 deletions
diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs
index b7d862d..cfc804f 100644
--- a/crates/shirabe/src/repository/array_repository.rs
+++ b/crates/shirabe/src/repository/array_repository.rs
@@ -321,11 +321,11 @@ impl RepositoryInterface for ArrayRepository {
r#type: Option<String>,
) -> anyhow::Result<Vec<SearchResult>> {
let regex = if mode == crate::repository::SEARCH_FULLTEXT {
- let parts = Preg::split("{\\s+}", &preg_quote(&query, None)).unwrap_or_default();
+ let parts = Preg::split("{\\s+}", &preg_quote(&query, None));
format!("{{(?:{})}}i", implode("|", &parts))
} else {
// vendor/name searches expect the caller to have preg_quoted the query
- let parts = Preg::split("{\\s+}", &query).unwrap_or_default();
+ let parts = Preg::split("{\\s+}", &query);
format!("{{(?:{})}}i", implode("|", &parts))
};
@@ -361,10 +361,9 @@ impl RepositoryInterface for ArrayRepository {
.get_description()
.unwrap_or_default()
),
- )
- .unwrap_or(false);
+ );
- if Preg::is_match(&regex, &name).unwrap_or(false) || fulltext_match {
+ if Preg::is_match(&regex, &name) || fulltext_match {
if mode == crate::repository::SEARCH_VENDOR {
matches.insert(
name.clone(),
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index 5994968..c1e2379 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -160,7 +160,7 @@ impl ComposerRepository {
.and_then(|v| v.as_string())
.unwrap_or("")
.to_string();
- if !Preg::is_match(r"{^[\w.]+\??://}", &url_str)? {
+ if !Preg::is_match(r"{^[\w.]+\??://}", &url_str) {
if let Some(local_file_path) = realpath(&url_str) {
// it is a local path, add file scheme
repo_config.insert(
@@ -252,7 +252,7 @@ impl ComposerRepository {
r"{^(?P<proto>https?)://packagist\.org/?$}i",
&url,
Some(&mut match_packagist),
- )? {
+ ) {
let proto = match_packagist
.get(&CaptureKey::ByName("proto".to_string()))
.cloned()
@@ -260,14 +260,14 @@ impl ComposerRepository {
url = format!("{}://repo.packagist.org", proto);
}
- let base_url_trimmed = Preg::replace(r"{(?:/[^/\\]+\.json)?(?:[?#].*)?$}", "", &url)?;
+ let base_url_trimmed = Preg::replace(r"{(?:/[^/\\]+\.json)?(?:[?#].*)?$}", "", &url);
let base_url = base_url_trimmed.trim_end_matches('/').to_string();
assert!(!base_url.is_empty());
let cache_dir = format!(
"{}/{}",
config.get("cache-repo-dir").as_string().unwrap_or(""),
- Preg::replace(r"{[^a-z0-9.]}i", "-", &Url::sanitize(url.clone()))?,
+ Preg::replace(r"{[^a-z0-9.]}i", "-", &Url::sanitize(url.clone())),
);
let cache = Cache::new(io.clone(), &cache_dir, Some("a-z0-9.$~"), None, false);
let version_parser = VersionParser::new();
@@ -436,7 +436,7 @@ impl ComposerRepository {
match &package_filter_regex {
Some(regex) => {
let results_refs: Vec<&str> = results.iter().map(|s| s.as_str()).collect();
- Ok(Preg::grep(regex, &results_refs)?)
+ Ok(Preg::grep(regex, &results_refs))
}
None => Ok(results),
}
@@ -774,12 +774,12 @@ impl ComposerRepository {
if mode == SEARCH_VENDOR {
let mut results: Vec<IndexMap<String, PhpMixed>> = Vec::new();
- let parts = Preg::split(r"{\s+}", &query)?;
+ let parts = Preg::split(r"{\s+}", &query);
let regex = format!("{{(?:{})}}i", parts.join("|"));
let vendor_names = self.get_vendor_names()?;
let vendor_names_refs: Vec<&str> = vendor_names.iter().map(|s| s.as_str()).collect();
- for name in Preg::grep(&regex, &vendor_names_refs)? {
+ for name in Preg::grep(&regex, &vendor_names_refs) {
let mut entry = IndexMap::new();
entry.insert("name".to_string(), PhpMixed::String(name));
entry.insert("description".to_string(), PhpMixed::String(String::new()));
@@ -796,7 +796,7 @@ impl ComposerRepository {
r"{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i",
&query,
Some(&mut match_groups),
- )? && self.list_url.is_some()
+ ) && self.list_url.is_some()
{
let q = match_groups
.get(&CaptureKey::ByName("query".to_string()))
@@ -839,12 +839,12 @@ impl ComposerRepository {
}
let mut results: Vec<IndexMap<String, PhpMixed>> = Vec::new();
- let parts = Preg::split(r"{\s+}", &query)?;
+ let parts = Preg::split(r"{\s+}", &query);
let regex = format!("{{(?:{})}}i", parts.join("|"));
let package_names = self.get_package_names(None)?;
let package_names_refs: Vec<&str> = package_names.iter().map(|s| s.as_str()).collect();
- for name in Preg::grep(&regex, &package_names_refs)? {
+ for name in Preg::grep(&regex, &package_names_refs) {
let mut entry = IndexMap::new();
entry.insert("name".to_string(), PhpMixed::String(name));
entry.insert("description".to_string(), PhpMixed::String(String::new()));
@@ -1737,7 +1737,7 @@ impl ComposerRepository {
for (name, constraint) in names_iter {
let name = strtolower(&name);
- let real_name = Preg::replace(r"{~dev$}", "", &name)?;
+ let real_name = Preg::replace(r"{~dev$}", "", &name);
// skip platform packages, root package and composer-plugin-api
if PlatformRepository::is_platform_package(&real_name) || real_name == "__root__" {
continue;
@@ -2410,7 +2410,7 @@ impl ComposerRepository {
if url.starts_with('/') {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r"{^[^:]++://[^/]*+}", &self.url, Some(&mut matches))? {
+ if Preg::is_match3(r"{^[^:]++://[^/]*+}", &self.url, Some(&mut matches)) {
return Ok(format!(
"{}{}",
matches
@@ -2722,7 +2722,7 @@ impl ComposerRepository {
// url-encode $ signs in URLs as bad proxies choke on them
if let Some(pos) = filename.find('$') {
- if pos > 0 && Preg::is_match(r"{^https?://}i", &filename)? {
+ if pos > 0 && Preg::is_match(r"{^https?://}i", &filename) {
filename = format!("{}%24{}", &filename[..pos], &filename[pos + 1..]);
}
}
@@ -3367,7 +3367,7 @@ impl ComposerRepository {
if let Some(ref patterns) = self.available_package_patterns {
for provider_regex in patterns.iter() {
- if Preg::is_match(provider_regex, name)? {
+ if Preg::is_match(provider_regex, name) {
return Ok(true);
}
}
diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs
index 57f3c87..38d5836 100644
--- a/crates/shirabe/src/repository/filesystem_repository.rs
+++ b/crates/shirabe/src/repository/filesystem_repository.rs
@@ -390,7 +390,7 @@ impl FilesystemRepository {
let pattern = "{(?(DEFINE)\n (?<number> -? \\s*+ \\d++ (?:\\.\\d++)? )\n (?<boolean> true | false | null )\n (?<strings> (?&string) (?: \\s*+ \\. \\s*+ (?&string))*+ )\n (?<string> (?: \" (?:[^\"\\\\$]*+ | \\\\ [\"\\\\0] )* \" | ' (?:[^'\\\\]*+ | \\\\ ['\\\\] )* ' ) )\n (?<array> array\\( \\s*+ (?: (?:(?&number)|(?&strings)) \\s*+ => \\s*+ (?: (?:__DIR__ \\s*+ \\. \\s*+)? (?&strings) | (?&value) ) \\s*+, \\s*+ )*+ \\s*+ \\) )\n (?<value> (?: (?&number) | (?&boolean) | (?&strings) | (?&array) ) )\n)\n^<\\?php\\s++return\\s++(?&array)\\s*+;$}ix";
if let Some(data) = installed_versions_data {
let mixed = PhpMixed::String(data.clone());
- if is_string(&mixed) && Preg::is_match(pattern, &trim(&data, None)).unwrap_or(false) {
+ if is_string(&mixed) && Preg::is_match(pattern, &trim(&data, None)) {
let replaced = Preg::replace(
r#"{=>\s*+__DIR__\s*+\.\s*+(['\"])}"#,
&format!(
@@ -399,10 +399,6 @@ impl FilesystemRepository {
),
&data,
);
- let replaced = match replaced {
- Ok(s) => s,
- Err(_) => return false,
- };
let evaluated = r#eval(&format!("?>{}", replaced));
InstalledVersions::reload(
evaluated
diff --git a/crates/shirabe/src/repository/filter_repository.rs b/crates/shirabe/src/repository/filter_repository.rs
index 0e05c25..90e211f 100644
--- a/crates/shirabe/src/repository/filter_repository.rs
+++ b/crates/shirabe/src/repository/filter_repository.rs
@@ -137,14 +137,14 @@ impl FilterRepository {
}
if let Some(only) = &self.only {
- return Preg::is_match(only, name).unwrap_or(false);
+ return Preg::is_match(only, name);
}
if self.exclude.is_none() {
return true;
}
- !Preg::is_match(self.exclude.as_ref().unwrap(), name).unwrap_or(false)
+ !Preg::is_match(self.exclude.as_ref().unwrap(), name)
}
}
diff --git a/crates/shirabe/src/repository/package_repository.rs b/crates/shirabe/src/repository/package_repository.rs
index 273cde0..5ba4840 100644
--- a/crates/shirabe/src/repository/package_repository.rs
+++ b/crates/shirabe/src/repository/package_repository.rs
@@ -77,7 +77,6 @@ impl PackageRepository {
pub fn get_repo_name(&self) -> String {
use crate::repository::RepositoryInterface;
Preg::replace(r"^array ", "package ", &self.inner.get_repo_name())
- .unwrap_or_else(|_| self.inner.get_repo_name())
}
}
diff --git a/crates/shirabe/src/repository/path_repository.rs b/crates/shirabe/src/repository/path_repository.rs
index 51acff0..cfd42e5 100644
--- a/crates/shirabe/src/repository/path_repository.rs
+++ b/crates/shirabe/src/repository/path_repository.rs
@@ -120,9 +120,9 @@ impl PathRepository {
let url_matches = self.get_url_matches()?;
if url_matches.is_empty() {
- if Preg::is_match(r"{[*{}]}", &self.url).unwrap_or(false) {
+ if Preg::is_match(r"{[*{}]}", &self.url) {
let mut url = self.url.clone();
- while Preg::is_match(r"{[*{}]}", &url).unwrap_or(false) {
+ while Preg::is_match(r"{[*{}]}", &url) {
url = shirabe_php_shim::dirname(&url);
}
// the parent directory before any wildcard exists, so we assume it is correctly configured but simply empty
diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs
index 39e29fb..3136065 100644
--- a/crates/shirabe/src/repository/platform_repository.rs
+++ b/crates/shirabe/src/repository/platform_repository.rs
@@ -218,8 +218,7 @@ impl PlatformRepository {
version = v;
}
Err(_) => {
- pretty_version = Preg::replace("#^([^~+-]+).*$#", "$1", &php_version_str)
- .unwrap_or(php_version_str);
+ pretty_version = Preg::replace("#^([^~+-]+).*$#", "$1", &php_version_str);
version = self
.version_parser
.as_ref()
@@ -352,9 +351,7 @@ impl PlatformRepository {
"/^librabbitmq version => (?<version>.+)$/im",
&info,
Some(&mut librabbitmq_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-librabbitmq", name),
@@ -373,9 +370,7 @@ impl PlatformRepository {
"/^AMQP protocol version => (?<version>.+)$/im",
&info,
Some(&mut protocol_matches),
- )
- .unwrap_or(false)
- {
+ ) {
let version_str = protocol_matches
.get(&CaptureKey::ByName("version".to_string()))
.cloned()
@@ -400,9 +395,7 @@ impl PlatformRepository {
"/^BZip2 Version => (?<version>.*),/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
name,
@@ -438,9 +431,7 @@ impl PlatformRepository {
"{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im",
&info,
Some(&mut ssl_matches),
- )
- .unwrap_or(false)
- {
+ ) {
let ssl_library_raw = ssl_matches
.get(&CaptureKey::ByName("library".to_string()))
.cloned()
@@ -476,9 +467,7 @@ impl PlatformRepository {
"{^\\(securetransport\\) ([a-z0-9]+)}",
&library,
Some(&mut securetransport_matches),
- )
- .unwrap_or(false)
- {
+ ) {
shortlib = "securetransport".to_string();
let m1 = securetransport_matches
.get(&CaptureKey::ByIndex(1))
@@ -510,9 +499,7 @@ impl PlatformRepository {
"{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im",
&info,
Some(&mut ssh_matches),
- )
- .unwrap_or(false)
- {
+ ) {
let ssh_library = ssh_matches
.get(&CaptureKey::ByName("library".to_string()))
.cloned()
@@ -537,9 +524,7 @@ impl PlatformRepository {
"{^ZLib Version => (?<version>.+)$}im",
&info,
Some(&mut zlib_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-zlib", name),
@@ -562,9 +547,7 @@ impl PlatformRepository {
"/^timelib version => (?<version>.+)$/im",
&info,
Some(&mut timelib_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-timelib", name),
@@ -583,19 +566,17 @@ impl PlatformRepository {
"/^Timezone Database => (?<source>internal|external)$/im",
&info,
Some(&mut zoneinfo_source_matches),
- )
- .unwrap_or(false)
- {
+ ) {
let external = zoneinfo_source_matches
.get(&CaptureKey::ByName("source".to_string()))
.map(|s| s == "external")
.unwrap_or(false);
let mut zoneinfo_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3("/^\"Olson\" Timezone Database Version => (?<version>.+?)(?:\\.system)?$/im",
- &info,
- Some(&mut zoneinfo_matches),)
- .unwrap_or(false)
- {
+ if Preg::is_match3(
+ "/^\"Olson\" Timezone Database Version => (?<version>.+?)(?:\\.system)?$/im",
+ &info,
+ Some(&mut zoneinfo_matches),
+ ) {
let zoneinfo_version = zoneinfo_matches
.get(&CaptureKey::ByName("version".to_string()))
.cloned()
@@ -635,9 +616,7 @@ impl PlatformRepository {
"/^libmagic => (?<version>.+)$/im",
&info,
Some(&mut magic_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libmagic", name),
@@ -673,9 +652,7 @@ impl PlatformRepository {
"/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im",
&info,
Some(&mut libjpeg_matches),
- )
- .unwrap_or(false)
- {
+ ) {
let libjpeg_version = libjpeg_matches
.get(&CaptureKey::ByName("version".to_string()))
.cloned()
@@ -696,9 +673,7 @@ impl PlatformRepository {
"/^libPNG Version => (?<version>.+)$/im",
&info,
Some(&mut libpng_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libpng", name),
@@ -716,9 +691,7 @@ impl PlatformRepository {
"/^FreeType Version => (?<version>.+)$/im",
&info,
Some(&mut freetype_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-freetype", name),
@@ -736,9 +709,7 @@ impl PlatformRepository {
"/^libXpm Version => (?<versionId>\\d+)$/im",
&info,
Some(&mut libxpm_matches),
- )
- .unwrap_or(false)
- {
+ ) {
let version_id: i64 = libxpm_matches
.get(&CaptureKey::ByName("versionId".to_string()))
.and_then(|s| s.parse().ok())
@@ -812,9 +783,7 @@ impl PlatformRepository {
"/^ICU version => (?<version>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
"icu",
@@ -834,9 +803,7 @@ impl PlatformRepository {
"/^ICU TZData version => (?<version>.*)$/im",
&info,
Some(&mut zoneinfo_matches),
- )
- .unwrap_or(false)
- {
+ ) {
let zi_version = zoneinfo_matches
.get(&CaptureKey::ByName("version".to_string()))
.cloned()
@@ -922,9 +889,7 @@ impl PlatformRepository {
"/^ImageMagick (?<version>[\\d.]+)(?:-(?<patch>\\d+))?/",
&image_magick_version_str,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
let mut version_built = matches
.get(&CaptureKey::ByName("version".to_string()))
.cloned()
@@ -953,15 +918,11 @@ impl PlatformRepository {
"/^Vendor Version => (?<versionId>\\d+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- && Preg::is_match3(
- "/^Vendor Name => (?<vendor>.+)$/im",
- &info,
- Some(&mut vendor_matches),
- )
- .unwrap_or(false)
- {
+ ) && Preg::is_match3(
+ "/^Vendor Name => (?<vendor>.+)$/im",
+ &info,
+ Some(&mut vendor_matches),
+ ) {
let version_id: i64 = matches
.get(&CaptureKey::ByName("versionId".to_string()))
.and_then(|s| s.parse().ok())
@@ -1016,9 +977,7 @@ impl PlatformRepository {
"/^libmbfl version => (?<version>.+)$/im",
&info,
Some(&mut libmbfl_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libmbfl", name),
@@ -1054,9 +1013,7 @@ impl PlatformRepository {
"/^(?:oniguruma|Multibyte regex \\(oniguruma\\)) version => (?<version>.+)$/im",
&info,
Some(&mut oniguruma_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-oniguruma", name),
@@ -1080,9 +1037,7 @@ impl PlatformRepository {
"/^libmemcached version => (?<version>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libmemcached", name),
@@ -1108,9 +1063,7 @@ impl PlatformRepository {
"{^(?:OpenSSL|LibreSSL)?\\s*(?<version>\\S+)}i",
&openssl_text_str,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
let version = matches
.get(&CaptureKey::ByName("version".to_string()))
.cloned()
@@ -1139,8 +1092,7 @@ impl PlatformRepository {
PhpMixed::String(s) => s.clone(),
_ => "".to_string(),
};
- let stripped = Preg::replace("{^(\\S+).*}", "$1", &pcre_version_str)
- .unwrap_or(pcre_version_str);
+ let stripped = Preg::replace("{^(\\S+).*}", "$1", &pcre_version_str);
self.add_library(&mut libraries, name, Some(&stripped), None, &[], &[])?;
let info = self.runtime.get_extension_info(name)?;
@@ -1151,9 +1103,7 @@ impl PlatformRepository {
"/^PCRE Unicode Version => (?<version>.+)$/im",
&info,
Some(&mut pcre_unicode_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-unicode", name),
@@ -1175,9 +1125,7 @@ impl PlatformRepository {
"/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-mysqlnd", name),
@@ -1199,9 +1147,7 @@ impl PlatformRepository {
"/^libmongoc bundled version => (?<version>.+)$/im",
&info,
Some(&mut libmongoc_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libmongoc", name),
@@ -1219,9 +1165,7 @@ impl PlatformRepository {
"/^libbson bundled version => (?<version>.+)$/im",
&info,
Some(&mut libbson_matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libbson", name),
@@ -1259,9 +1203,7 @@ impl PlatformRepository {
"/^PostgreSQL\\(libpq\\) Version => (?<version>.*)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libpq", name),
@@ -1284,9 +1226,7 @@ impl PlatformRepository {
"/^PostgreSQL\\(libpq\\) Version => (?<version>.*)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libpq", name),
@@ -1310,9 +1250,7 @@ impl PlatformRepository {
"/^libpq => (?<compiled>.+) => (?<linked>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libpq", name),
@@ -1391,9 +1329,7 @@ impl PlatformRepository {
"/^SQLite Library => (?<version>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-sqlite", name),
@@ -1415,9 +1351,7 @@ impl PlatformRepository {
"/^libssh2 version => (?<version>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libssh2", name),
@@ -1452,9 +1386,7 @@ impl PlatformRepository {
"/^libxslt compiled against libxml Version => (?<version>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
"libxslt-libxml",
@@ -1476,9 +1408,7 @@ impl PlatformRepository {
"/^LibYAML Version => (?<version>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
&format!("{}-libyaml", name),
@@ -1539,9 +1469,7 @@ impl PlatformRepository {
"/^Linked Version => (?<version>.+)$/im",
&info,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
self.add_library(
&mut libraries,
name,
@@ -1574,8 +1502,7 @@ impl PlatformRepository {
version = v;
}
Err(_) => {
- pretty_version = Preg::replace("#^([^~+-]+).*$#", "$1", &hhvm_version)
- .unwrap_or(hhvm_version);
+ pretty_version = Preg::replace("#^([^~+-]+).*$#", "$1", &hhvm_version);
version = self
.version_parser
.as_ref()
@@ -1739,9 +1666,7 @@ impl PlatformRepository {
"{^(\\d+\\.\\d+\\.\\d+(?:\\.\\d+)?)}",
&pretty_version,
Some(&mut m),
- )
- .unwrap_or(false)
- {
+ ) {
pretty_version = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
} else {
pretty_version = "0".to_string();
@@ -1869,7 +1794,7 @@ impl PlatformRepository {
return cached;
}
- let result = Preg::is_match(Self::PLATFORM_PACKAGE_REGEX, name).unwrap_or(false);
+ let result = Preg::is_match(Self::PLATFORM_PACKAGE_REGEX, name);
cache.insert(name.to_string(), result);
result
}
diff --git a/crates/shirabe/src/repository/repository_factory.rs b/crates/shirabe/src/repository/repository_factory.rs
index 5543a9e..71b1471 100644
--- a/crates/shirabe/src/repository/repository_factory.rs
+++ b/crates/shirabe/src/repository/repository_factory.rs
@@ -332,7 +332,7 @@ impl RepositoryFactory {
let mut name = match index {
PhpMixed::Int(_) => {
if let Some(url) = repo.get("url").and_then(|v| v.as_string()) {
- Preg::replace("{^https?://}i", "", url).unwrap_or_else(|_| url.to_string())
+ Preg::replace("{^https?://}i", "", url)
} else {
index.as_string().unwrap_or("").to_string()
}
@@ -351,7 +351,7 @@ impl RepositoryFactory {
existing_repos: &IndexMap<String, RepositoryInterfaceHandle>,
) -> String {
let mut name = if let Some(url) = repo.get("url").and_then(|v| v.as_string()) {
- Preg::replace("{^https?://}i", "", url).unwrap_or_else(|_| url.to_string())
+ Preg::replace("{^https?://}i", "", url)
} else {
index.to_string()
};
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 82794a4..df52820 100644
--- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs
+++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
@@ -605,7 +605,7 @@ impl ForgejoDriver {
let links = explode(",", &header);
for link in links {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match3(r#"{<(.+?)>; *rel="next"}"#, &link, Some(&mut m)).unwrap_or(false) {
+ if Preg::match3(r#"{<(.+?)>; *rel="next"}"#, &link, Some(&mut m)) {
if let Some(url) = m.get(&CaptureKey::ByIndex(1)) {
return Some(url.clone());
}
diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs
index 15328c0..c205379 100644
--- a/crates/shirabe/src/repository/vcs/fossil_driver.rs
+++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs
@@ -85,7 +85,7 @@ impl FossilDriver {
.into());
}
- let local_name = Preg::replace(r"{[^a-z0-9]}i", "-", &self.inner.url)?;
+ let local_name = Preg::replace(r"{[^a-z0-9]}i", "-", &self.inner.url);
self.repo_file = Some(format!("{}/{}.fossil", cache_repo_dir, local_name));
self.checkout_dir = format!("{}/{}/", cache_vcs_dir, local_name);
@@ -304,7 +304,7 @@ impl FossilDriver {
Some(self.checkout_dir.clone()),
);
for branch in self.inner.process.borrow().split_lines(&output) {
- let branch = Preg::replace(r"/^\*/", "", &branch.trim())?;
+ let branch = Preg::replace(r"/^\*/", "", &branch.trim());
let branch = branch.trim().to_string();
branches.insert(branch.clone(), branch);
}
@@ -322,13 +322,11 @@ impl FossilDriver {
if Preg::is_match(
r"#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i",
url,
- )
- .unwrap_or(false)
- {
+ ) {
return Ok(true);
}
- if Preg::is_match(r"!/fossil/|\.fossil!", url).unwrap_or(false) {
+ if Preg::is_match(r"!/fossil/|\.fossil!", url) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index 674f849..b0985e5 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -91,9 +91,7 @@ impl GitBitbucketDriver {
r"#^https?://bitbucket\.org/([^/]+)/([^/]+?)(?:\.git|/?)?$#i",
&self.inner.url,
Some(&mut m),
- )
- .unwrap_or(false)
- {
+ ) {
return Err(InvalidArgumentException {
message: format!(
"The Bitbucket repository URL {} is invalid. It must be the HTTPS URL of a Bitbucket repository.",
@@ -799,8 +797,7 @@ impl GitBitbucketDriver {
r"/https:\/\/([^@]+@)?/",
"https://",
m.get("href").and_then(|v| v.as_string()).unwrap_or(""),
- )
- .unwrap_or_default();
+ );
}
}
}
@@ -862,9 +859,7 @@ impl GitBitbucketDriver {
if !Preg::is_match(
r"#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i",
url,
- )
- .unwrap_or(false)
- {
+ ) {
return Ok(false);
}
diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs
index 10353f3..3c950bb 100644
--- a/crates/shirabe/src/repository/vcs/git_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_driver.rs
@@ -51,7 +51,7 @@ impl GitDriver {
pub fn initialize(&mut self) -> anyhow::Result<()> {
let cache_url;
if Filesystem::is_local_path(&self.inner.url) {
- self.inner.url = Preg::replace(r"{[\\/]\.git/?$}", "", &self.inner.url)?;
+ self.inner.url = Preg::replace(r"{[\\/]\.git/?$}", "", &self.inner.url);
if !is_dir(&self.inner.url) {
return Err(RuntimeException {
message: format!(
@@ -88,7 +88,7 @@ impl GitDriver {
r"{[^a-z0-9.]}i",
"-",
&Url::sanitize(self.inner.url.clone())
- )?
+ )
);
GitUtil::clean_env(&self.inner.process);
@@ -108,7 +108,7 @@ impl GitDriver {
.into());
}
- if Preg::is_match(r"{^ssh://[^@]+@[^:]+:[^0-9]+}", &self.inner.url).unwrap_or(false) {
+ if Preg::is_match(r"{^ssh://[^@]+@[^:]+:[^0-9]+}", &self.inner.url) {
return Err(InvalidArgumentException {
message: format!(
"The source URL {} is invalid, ssh URLs should have a port number after \":\".\nUse ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.",
@@ -161,7 +161,7 @@ impl GitDriver {
&format!(
"{}/{}",
cache_repo_dir,
- Preg::replace(r"{[^a-z0-9.]}i", "-", &Url::sanitize(cache_url))?
+ Preg::replace(r"{[^a-z0-9.]}i", "-", &Url::sanitize(cache_url))
),
None,
None,
@@ -215,7 +215,7 @@ impl GitDriver {
for branch in &branches {
if !branch.is_empty() {
let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match3(r"{^\* +(\S+)}", branch, Some(&mut caps)).unwrap_or(false) {
+ if Preg::match3(r"{^\* +(\S+)}", branch, Some(&mut caps)) {
if let Some(name) = caps.get(&CaptureKey::ByIndex(1)) {
self.root_identifier = Some(name.clone());
break;
@@ -338,9 +338,7 @@ impl GitDriver {
r"{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}",
&tag,
Some(&mut caps),
- )
- .unwrap_or(false)
- {
+ ) {
if let (Some(hash), Some(name)) = (
caps.get(&CaptureKey::ByIndex(1)),
caps.get(&CaptureKey::ByIndex(2)),
@@ -375,17 +373,13 @@ impl GitDriver {
Some(self.repo_dir.clone()),
);
for branch in self.inner.process.borrow().split_lines(&output) {
- if !branch.is_empty()
- && !Preg::is_match(r"{^ *[^/]+/HEAD }", &branch).unwrap_or(false)
- {
+ if !branch.is_empty() && !Preg::is_match(r"{^ *[^/]+/HEAD }", &branch) {
let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
if Preg::match3(
r"{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}",
&branch,
Some(&mut caps),
- )
- .unwrap_or(false)
- {
+ ) {
if let (Some(name), Some(hash)) = (
caps.get(&CaptureKey::ByIndex(1)),
caps.get(&CaptureKey::ByIndex(2)),
@@ -413,9 +407,7 @@ impl GitDriver {
if Preg::is_match(
r"#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i",
url,
- )
- .unwrap_or(false)
- {
+ ) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 64ed4d3..864b4f3 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -78,9 +78,7 @@ impl GitHubDriver {
r"#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#",
&self.inner.url,
Some(&mut match_),
- )
- .unwrap_or(false)
- {
+ ) {
return Err(InvalidArgumentException {
message: format!(
"The GitHub repository URL {} is invalid.",
@@ -501,10 +499,10 @@ impl GitHubDriver {
let mut result: Vec<IndexMap<String, PhpMixed>> = vec![];
let mut key: Option<String> = None;
- for line in Preg::split(r"{\r?\n}", &funding).unwrap_or_default() {
+ for line in Preg::split(r"{\r?\n}", &funding) {
let line = trim(&line, None);
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r"{^(\w+)\s*:\s*(.+)$}", &line, Some(&mut m)).unwrap_or(false) {
+ if Preg::is_match3(r"{^(\w+)\s*:\s*(.+)$}", &line, Some(&mut m)) {
let g1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
let g2 = m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
if g2 == "[" {
@@ -512,12 +510,11 @@ impl GitHubDriver {
continue;
}
let mut m2: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r"{^\[(.*?)\](?:\s*#.*)?$}", &g2, Some(&mut m2)).unwrap_or(false)
- {
+ if Preg::is_match3(r"{^\[(.*?)\](?:\s*#.*)?$}", &g2, Some(&mut m2)) {
let inner = m2.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
for item in array_map(
|s: &String| trim(s, None),
- &Preg::split(r#"{[\'\"]?\s*,\s*[\'\"]?}"#, &inner).unwrap_or_default(),
+ &Preg::split(r#"{[\'\"]?\s*,\s*[\'\"]?}"#, &inner),
) {
let mut entry = IndexMap::new();
entry.insert("type".to_string(), PhpMixed::String(g1.clone()));
@@ -527,9 +524,7 @@ impl GitHubDriver {
);
result.push(entry);
}
- } else if Preg::is_match3(r"{^([^#].*?)(?:\s+#.*)?$}", &g2, Some(&mut m2))
- .unwrap_or(false)
- {
+ } else if Preg::is_match3(r"{^([^#].*?)(?:\s+#.*)?$}", &g2, Some(&mut m2)) {
let mut entry = IndexMap::new();
entry.insert("type".to_string(), PhpMixed::String(g1.clone()));
entry.insert(
@@ -542,18 +537,15 @@ impl GitHubDriver {
result.push(entry);
}
key = None;
- } else if Preg::is_match3(r"{^(\w+)\s*:\s*#\s*$}", &line, Some(&mut m)).unwrap_or(false)
- {
+ } else if Preg::is_match3(r"{^(\w+)\s*:\s*#\s*$}", &line, Some(&mut m)) {
key = Some(m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default());
} else if key.is_some() && {
let mut tmp: IndexMap<CaptureKey, String> = IndexMap::new();
- Preg::is_match3(r"{^-\s*(.+)(?:\s+#.*)?$}", &line, Some(&mut m)).unwrap_or(false)
- || Preg::is_match3(r"{^(.+),(?:\s*#.*)?$}", &line, Some(&mut tmp))
- .unwrap_or(false)
- && {
- m = tmp;
- true
- }
+ Preg::is_match3(r"{^-\s*(.+)(?:\s+#.*)?$}", &line, Some(&mut m))
+ || Preg::is_match3(r"{^(.+),(?:\s*#.*)?$}", &line, Some(&mut tmp)) && {
+ m = tmp;
+ true
+ }
} {
let mut entry = IndexMap::new();
entry.insert(
@@ -688,9 +680,7 @@ impl GitHubDriver {
if !array_key_exists("scheme", &bits_map)
&& !array_key_exists("host", &bits_map)
{
- if Preg::is_match(r"{^[a-z0-9-]++\.[a-z]{2,3}$}", &item_url)
- .unwrap_or(false)
- {
+ if Preg::is_match(r"{^[a-z0-9-]++\.[a-z]{2,3}$}", &item_url) {
result[key_idx].insert(
"url".to_string(),
PhpMixed::String(format!("https://{}", item_url)),
@@ -956,9 +946,7 @@ impl GitHubDriver {
r"#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#",
url,
Some(&mut matches),
- )
- .unwrap_or(false)
- {
+ ) {
return Ok(false);
}
@@ -973,9 +961,7 @@ impl GitHubDriver {
.unwrap_or_default()
});
if !in_array(
- PhpMixed::String(strtolower(
- &Preg::replace(r"{^www\.}i", "", &origin_url).unwrap_or_default(),
- )),
+ PhpMixed::String(strtolower(&Preg::replace(r"{^www\.}i", "", &origin_url))),
&config.borrow().get("github-domains"),
false,
) {
@@ -1320,7 +1306,7 @@ impl GitHubDriver {
let links = explode(",", &header);
for link in &links {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut m)).unwrap_or(false) {
+ if Preg::is_match3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut m)) {
return Some(m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default());
}
}
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index a123a24..fc09108 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -84,7 +84,7 @@ impl GitLabDriver {
/// SSH urls use https by default. Set "secure-http": false on the repository config to use http instead.
pub fn initialize(&mut self) -> Result<()> {
let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match3(Self::URL_REGEX, &self.inner.url, Some(&mut match_)).unwrap_or(false) {
+ if !Preg::is_match3(Self::URL_REGEX, &self.inner.url, Some(&mut match_)) {
return Err(InvalidArgumentException {
message: format!(
"The GitLab repository URL {} is invalid. It must be the HTTP URL of a GitLab project.",
@@ -202,8 +202,7 @@ impl GitLabDriver {
.get(&CaptureKey::ByName("repo".to_string()))
.cloned()
.unwrap_or_default(),
- )
- .unwrap_or_default();
+ );
self.inner.cache = Some(Cache::new(
self.inner.io.clone(),
@@ -429,7 +428,7 @@ impl GitLabDriver {
// Convert the root identifier to a cacheable commit id
let mut identifier = identifier.to_string();
- if !Preg::is_match(r"{[a-f0-9]{40}}i", &identifier).unwrap_or(false) {
+ if !Preg::is_match(r"{[a-f0-9]{40}}i", &identifier) {
let branches = self.get_branches()?;
if let Some(sha) = branches.get(&identifier) {
identifier = sha.clone();
@@ -987,7 +986,7 @@ impl GitLabDriver {
_deep: bool,
) -> anyhow::Result<bool> {
let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match3(Self::URL_REGEX, url, Some(&mut match_)).unwrap_or(false) {
+ if !Preg::is_match3(Self::URL_REGEX, url, Some(&mut match_)) {
return Ok(false);
}
@@ -1055,9 +1054,7 @@ impl GitLabDriver {
let links = explode(",", &header);
for link in &links {
let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut match_))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut match_)) {
return Some(
match_
.get(&CaptureKey::ByIndex(1))
@@ -1117,9 +1114,7 @@ impl GitLabDriver {
false,
) || (port_number.is_some()
&& in_array(
- PhpMixed::String(
- Preg::replace(r"{:\d+}", "", &guessed_domain).unwrap_or_default(),
- ),
+ PhpMixed::String(Preg::replace(r"{:\d+}", "", &guessed_domain)),
configured_domains,
false,
))
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index c76f496..63a400c 100644
--- a/crates/shirabe/src/repository/vcs/hg_driver.rs
+++ b/crates/shirabe/src/repository/vcs/hg_driver.rs
@@ -61,7 +61,7 @@ impl HgDriver {
}
let sanitized =
- Preg::replace(r"{[^a-z0-9]}i", "-", &Url::sanitize(self.inner.url.clone()))?;
+ Preg::replace(r"{[^a-z0-9]}i", "-", &Url::sanitize(self.inner.url.clone()));
self.repo_dir = format!("{}/{}/", cache_vcs_dir, sanitized);
let mut fs = Filesystem::new(None);
@@ -244,7 +244,7 @@ impl HgDriver {
for tag in self.inner.process.borrow().split_lines(&output) {
if !tag.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match3(r"^([^\s]+)\s+\d+:(.*)$", &tag, Some(&mut m)).unwrap_or(false) {
+ if Preg::match3(r"^([^\s]+)\s+\d+:(.*)$", &tag, Some(&mut m)) {
tags.insert(
m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(),
m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
@@ -274,9 +274,7 @@ impl HgDriver {
for branch in self.inner.process.borrow().split_lines(&output) {
if !branch.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match3(r"^([^\s]+)\s+\d+:([a-f0-9]+)", &branch, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::match3(r"^([^\s]+)\s+\d+:([a-f0-9]+)", &branch, Some(&mut m)) {
let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
if !name.starts_with('-') {
branches.insert(
@@ -297,9 +295,7 @@ impl HgDriver {
for branch in self.inner.process.borrow().split_lines(&output) {
if !branch.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match3(r"^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$", &branch, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::match3(r"^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$", &branch, Some(&mut m)) {
let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
if !name.starts_with('-') {
bookmarks.insert(
@@ -328,9 +324,7 @@ impl HgDriver {
if Preg::is_match(
r"#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i",
url,
- )
- .unwrap_or(false)
- {
+ ) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs
index 65f2856..10cf913 100644
--- a/crates/shirabe/src/repository/vcs/perforce_driver.rs
+++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs
@@ -188,7 +188,7 @@ impl PerforceDriver {
url: &str,
deep: bool,
) -> anyhow::Result<bool> {
- if deep || Preg::is_match(r"#\b(perforce|p4)\b#i", url).unwrap_or(false) {
+ if deep || Preg::is_match(r"#\b(perforce|p4)\b#i", url) {
return Ok(Perforce::check_server_exists(
url,
&mut ProcessExecutor::new(Some(io)),
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index 71d8499..b48ce99 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -117,7 +117,7 @@ impl SvnDriver {
.get("cache-repo-dir")
.as_string()
.unwrap_or(""),
- Preg::replace(r"{[^a-z0-9.]}i", "-", &Url::sanitize(self.base_url.clone()))?,
+ Preg::replace(r"{[^a-z0-9.]}i", "-", &Url::sanitize(self.base_url.clone())),
),
None,
None,
@@ -160,7 +160,7 @@ impl SvnDriver {
}
pub(crate) fn should_cache(&self, identifier: &str) -> bool {
- self.inner.cache.is_some() && Preg::is_match(r"{@\d+$}", identifier).unwrap_or(false)
+ self.inner.cache.is_some() && Preg::is_match(r"{@\d+$}", identifier)
}
pub fn get_composer_information(
@@ -263,7 +263,7 @@ impl SvnDriver {
pub fn get_file_content(&mut self, file: &str, identifier: &str) -> Result<Option<String>> {
let identifier = format!("/{}/", trim(identifier, Some("/")));
- let (path, rev) = if let Ok(Some(m)) =
+ let (path, rev) = if let Some(m) =
Preg::is_match_with_indexed_captures(r"{^(.+?)(@\d+)?/$}", &identifier)
{
if m.get(2).is_some() {
@@ -300,7 +300,7 @@ impl SvnDriver {
pub fn get_change_date(&mut self, identifier: &str) -> Result<Option<DateTime<FixedOffset>>> {
let identifier = format!("/{}/", trim(identifier, Some("/")));
- let (path, rev) = if let Ok(Some(m)) =
+ let (path, rev) = if let Some(m) =
Preg::is_match_with_indexed_captures(r"{^(.+?)(@\d+)?/$}", &identifier)
{
if m.get(2).is_some() {
@@ -322,9 +322,7 @@ impl SvnDriver {
for line in self.inner.process.borrow().split_lines(&output) {
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r"{^Last Changed Date: ([^(]+)}", &line, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r"{^Last Changed Date: ([^(]+)}", &line, Some(&mut m)) {
let date_str = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
return Ok(shirabe_php_shim::date_create::<Utc>(date_str.trim())
.ok()
@@ -354,9 +352,7 @@ impl SvnDriver {
let line = trim(&line, None);
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m)) {
let rev: i64 = m
.get(&CaptureKey::ByIndex(1))
.and_then(|s| s.parse().ok())
@@ -405,9 +401,7 @@ impl SvnDriver {
let line = trim(&line, None);
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m)) {
let rev: i64 = m
.get(&CaptureKey::ByIndex(1))
.and_then(|s| s.parse().ok())
@@ -447,9 +441,7 @@ impl SvnDriver {
let line = trim(&line, None);
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m)) {
let rev: i64 = m
.get(&CaptureKey::ByIndex(1))
.and_then(|s| s.parse().ok())
@@ -485,7 +477,7 @@ impl SvnDriver {
deep: bool,
) -> Result<bool> {
let url = Self::normalize_url(url);
- if Preg::is_match(r"#(^svn://|^svn\+ssh://|svn\.)#i", &url).unwrap_or(false) {
+ if Preg::is_match(r"#(^svn://|^svn\+ssh://|svn\.)#i", &url) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs
index b197676..d1bb3cc 100644
--- a/crates/shirabe/src/repository/vcs/vcs_driver.rs
+++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs
@@ -58,7 +58,7 @@ impl VcsDriverBase {
}
pub fn should_cache(&self, identifier: &str) -> bool {
- self.cache.is_some() && Preg::is_match("{^[a-f0-9]{40}$}iD", identifier).unwrap_or(false)
+ self.cache.is_some() && Preg::is_match("{^[a-f0-9]{40}$}iD", identifier)
}
pub fn get_scheme(&self) -> &str {
@@ -207,7 +207,7 @@ pub trait VcsDriver: VcsDriverInterface {
fn cache_mut(&mut self) -> Option<&mut Cache>;
fn should_cache(&self, identifier: &str) -> bool {
- self.cache().is_some() && Preg::is_match("{^[a-f0-9]{40}$}iD", identifier).unwrap_or(false)
+ self.cache().is_some() && Preg::is_match("{^[a-f0-9]{40}$}iD", identifier)
}
fn get_composer_information(
diff --git a/crates/shirabe/src/repository/vcs_repository.rs b/crates/shirabe/src/repository/vcs_repository.rs
index ef58fe2..ebab76f 100644
--- a/crates/shirabe/src/repository/vcs_repository.rs
+++ b/crates/shirabe/src/repository/vcs_repository.rs
@@ -443,7 +443,7 @@ impl VcsRepository {
data.get("version")
.and_then(|v| v.as_string())
.unwrap_or(""),
- )?),
+ )),
);
data.insert(
"version_normalized".to_string(),
@@ -453,7 +453,7 @@ impl VcsRepository {
data.get("version_normalized")
.and_then(|v| v.as_string())
.unwrap_or(""),
- )?),
+ )),
);
// make sure tag do not contain the default-branch marker
@@ -468,7 +468,7 @@ impl VcsRepository {
// broken package, version doesn't match tag
if version_normalized != parsed_tag {
if is_very_verbose {
- if Preg::is_match(r"{(^dev-|[.-]?dev$)}i", &parsed_tag).unwrap_or(false) {
+ if Preg::is_match(r"{(^dev-|[.-]?dev$)}i", &parsed_tag) {
self.io.write_error(&format!(
"<warning>Skipped tag {}, invalid tag name, tags can not use dev prefixes or suffixes</warning>",
tag
@@ -620,7 +620,7 @@ impl VcsRepository {
version = format!(
"{}{}",
prefix,
- Preg::replace(r"{(\.9{7})+}", ".x", &parsed_branch)?
+ Preg::replace(r"{(\.9{7})+}", ".x", &parsed_branch)
);
}