diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-14 11:24:36 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-14 11:28:19 +0900 |
| commit | 716f44031a39c5e43fb441ecc470db76efc23dd4 (patch) | |
| tree | e6f4a31e4bf55a0a8efb06d9dd4844c567e7390f /crates/shirabe/src/downloader/svn_downloader.rs | |
| parent | ef9118c788c1cbb22ca7721b6a9e40c2bf2fe243 (diff) | |
| download | php-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/downloader/svn_downloader.rs')
| -rw-r--r-- | crates/shirabe/src/downloader/svn_downloader.rs | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index e66d3ae..03fd292 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -281,7 +281,6 @@ impl VcsDownloader for SvnDownloader { let changes_str = changes.unwrap(); let changes: Vec<String> = Preg::split(r"{\s*\r?\n\s*}", &changes_str) - .unwrap_or_default() .into_iter() .map(|elem| format!(" {}", elem)) .collect(); @@ -367,8 +366,8 @@ impl VcsDownloader for SvnDownloader { to_reference: &str, path: &str, ) -> anyhow::Result<String> { - if Preg::is_match(r"{@(\d+)$}", from_reference).unwrap_or(false) - && Preg::is_match(r"{@(\d+)$}", to_reference).unwrap_or(false) + if Preg::is_match(r"{@(\d+)$}", from_reference) + && Preg::is_match(r"{@(\d+)$}", to_reference) { // retrieve the svn base url from the checkout folder let command = vec![ @@ -399,25 +398,22 @@ impl VcsDownloader for SvnDownloader { let url_pattern = "#<url>(.*)</url>#"; let mut matches: IndexMap<CaptureKey, String> = IndexMap::new(); - let base_url = - if Preg::match3(url_pattern, &output, Some(&mut matches)).unwrap_or(false) { - matches - .get(&CaptureKey::ByIndex(1)) - .cloned() - .unwrap_or_default() - } else { - return Err(RuntimeException { - message: format!("Unable to determine svn url for path {}", path), - code: 0, - } - .into()); - }; + let base_url = if Preg::match3(url_pattern, &output, Some(&mut matches)) { + matches + .get(&CaptureKey::ByIndex(1)) + .cloned() + .unwrap_or_default() + } else { + return Err(RuntimeException { + message: format!("Unable to determine svn url for path {}", path), + code: 0, + } + .into()); + }; // strip paths from references and only keep the actual revision - let from_revision = - Preg::replace(r"{.*@(\d+)$}", "$1", &from_reference).unwrap_or_default(); - let to_revision = - Preg::replace(r"{.*@(\d+)$}", "$1", &to_reference).unwrap_or_default(); + let from_revision = Preg::replace(r"{.*@(\d+)$}", "$1", &from_reference); + let to_revision = Preg::replace(r"{.*@(\d+)$}", "$1", &to_reference); let command = vec![ "svn".to_string(), @@ -474,13 +470,11 @@ impl ChangeReportInterface for SvnDownloader { Some(path.to_string()), ); - Ok( - if Preg::is_match("{^ *[^X ] +}m", &output).unwrap_or(false) { - Some(output) - } else { - None - }, - ) + Ok(if Preg::is_match("{^ *[^X ] +}m", &output) { + Some(output) + } else { + None + }) } } |
