aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-14 11:24:36 +0900
committernsfisis <nsfisis@gmail.com>2026-06-14 11:28:19 +0900
commit716f44031a39c5e43fb441ecc470db76efc23dd4 (patch)
treee6f4a31e4bf55a0a8efb06d9dd4844c567e7390f /crates/shirabe/src/repository/vcs
parentef9118c788c1cbb22ca7721b6a9e40c2bf2fe243 (diff)
downloadphp-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.tar.gz
php-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.tar.zst
php-shirabe-716f44031a39c5e43fb441ecc470db76efc23dd4.zip
refactor(pcre): drop Result from Preg method return types
The Preg methods panic on PCRE failure (per the file header rationale), so their anyhow::Result wrappers never carried an Err. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
-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
10 files changed, 56 insertions, 104 deletions
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(