aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/downloader')
-rw-r--r--crates/shirabe/src/downloader/download_manager.rs4
-rw-r--r--crates/shirabe/src/downloader/fossil_downloader.rs4
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs26
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs12
-rw-r--r--crates/shirabe/src/downloader/zip_downloader.rs9
5 files changed, 24 insertions, 31 deletions
diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs
index f2360f9d..85e05bea 100644
--- a/crates/shirabe/src/downloader/download_manager.rs
+++ b/crates/shirabe/src/downloader/download_manager.rs
@@ -11,7 +11,7 @@ use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_keys,
- array_reverse, array_shift, dirname, implode, in_array_strict, preg_match2, preg_quote, rtrim,
+ array_reverse, array_shift, dirname, implode, in_array_strict, preg_match, preg_quote, rtrim,
str_replace, strtolower, usort,
};
@@ -430,7 +430,7 @@ impl DownloadManager {
"{{^{}$}}i",
str_replace("\\*", ".*", &preg_quote(pattern, None)),
);
- if preg_match2(&pattern_regex, &package.get_name(), 0).is_some() {
+ if preg_match(&pattern_regex, &package.get_name()).is_some() {
if "dist" == preference || (!package.is_dev() && "auto" == preference) {
return "dist".to_string();
}
diff --git a/crates/shirabe/src/downloader/fossil_downloader.rs b/crates/shirabe/src/downloader/fossil_downloader.rs
index e7b3a20d..40d5153f 100644
--- a/crates/shirabe/src/downloader/fossil_downloader.rs
+++ b/crates/shirabe/src/downloader/fossil_downloader.rs
@@ -13,7 +13,7 @@ use crate::util::Filesystem;
use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, impl_php_class, php_regex, preg_match2, preg_split,
+ PhpMixed, RuntimeException, impl_php_class, php_regex, preg_match, preg_split,
};
#[derive(Debug)]
@@ -228,7 +228,7 @@ impl VcsDownloader for FossilDownloader {
};
for line in lines {
- if preg_match2(&match_pattern, &line, 0).is_some() {
+ if preg_match(&match_pattern, &line).is_some() {
break;
}
log.push_str(&line);
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index 6e79576d..be3205b5 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -19,7 +19,7 @@ use crate::util::Url;
use indexmap::IndexMap;
use shirabe_php_shim::{
CaptureKey, CmpOp, PhpMixed, RuntimeException, array_map, basename, dirname, impl_php_class,
- implode, in_array_strict, is_dir, php_regex, preg_match_all, preg_match2, preg_quote,
+ implode, in_array_strict, is_dir, php_regex, preg_match, preg_match_all, preg_quote,
preg_replace, preg_split, realpath, rtrim, strlen, strpos, substr, trim, version_compare,
};
@@ -94,7 +94,7 @@ impl GitDownloader {
}
let mut refs = trim(&output, None);
- let Some(head_match) = preg_match2(php_regex!(r"{^([a-f0-9]+) HEAD$}mi"), &refs, 0) else {
+ let Some(head_match) = preg_match(php_regex!(r"{^([a-f0-9]+) HEAD$}mi"), &refs) else {
// could not match the HEAD for some reason
return Ok(None);
};
@@ -298,12 +298,11 @@ impl GitDownloader {
// check whether non-commitish are branches or tags, and fetch branches with the remote name
let git_ref = reference.to_string();
- if preg_match2(php_regex!(r"{^[a-f0-9]{40}$}"), reference, 0).is_none()
+ if preg_match(php_regex!(r"{^[a-f0-9]{40}$}"), reference).is_none()
&& branches.is_some()
- && preg_match2(
+ && preg_match(
format!("{{^\\s+composer/{}$}}m", preg_quote(reference, None)),
branches.as_deref().unwrap_or(""),
- 0,
)
.is_some()
{
@@ -346,19 +345,17 @@ impl GitDownloader {
}
// try to checkout branch by name and then reset it so it's on the proper branch name
- if preg_match2(php_regex!(r"{^[a-f0-9]{40}$}"), reference, 0).is_some() {
+ if preg_match(php_regex!(r"{^[a-f0-9]{40}$}"), reference).is_some() {
// add 'v' in front of the branch if it was stripped when generating the pretty name
if branches.is_some()
- && preg_match2(
+ && preg_match(
format!("{{^\\s+composer/{}$}}m", preg_quote(&branch, None)),
branches.as_deref().unwrap_or(""),
- 0,
)
.is_none()
- && preg_match2(
+ && preg_match(
format!("{{^\\s+composer/v{}$}}m", preg_quote(&branch, None)),
branches.as_deref().unwrap_or(""),
- 0,
)
.is_some()
{
@@ -505,13 +502,12 @@ impl GitDownloader {
fn set_push_url(&self, path: &str, url: &str) {
// set push url for github projects
- if let Some(match_) = preg_match2(
+ if let Some(match_) = preg_match(
format!(
"{{^(?:https?|git)://{}/([^/]+)/([^/]+?)(?:\\.git)?$}}",
GitUtil::get_github_domains_regex(&self.inner.config.borrow())
),
url,
- 0,
) {
let protocols = self.inner.config.borrow_mut().get("github-protocols");
let m1 = match_.get(1).unwrap_or_default().to_string();
@@ -647,7 +643,7 @@ impl GitDownloader {
fn get_short_hash(&self, reference: &str) -> String {
if !self.inner.io.is_verbose()
- && preg_match2(php_regex!(r"{^[0-9a-f]{40}$}"), reference, 0).is_some()
+ && preg_match(php_regex!(r"{^[0-9a-f]{40}$}"), reference).is_some()
{
return substr(reference, 0, Some(10));
}
@@ -1101,9 +1097,9 @@ impl VcsDownloader for GitDownloader {
Some(&path),
) == 0
&& let Some(origin_match) =
- preg_match2(php_regex!(r"{^origin\s+(?P<url>\S+)}m"), &output, 0)
+ preg_match(php_regex!(r"{^origin\s+(?P<url>\S+)}m"), &output)
&& let Some(composer_match) =
- preg_match2(php_regex!(r"{^composer\s+(?P<url>\S+)}m"), &output, 0)
+ preg_match(php_regex!(r"{^composer\s+(?P<url>\S+)}m"), &output)
{
let origin_url = origin_match.name("url").unwrap_or_default().to_string();
let composer_url = composer_match.name("url").unwrap_or_default().to_string();
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index a31e89c9..42152eb3 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -16,8 +16,8 @@ use crate::util::ProcessExecutor;
use crate::util::Svn as SvnUtil;
use indexmap::IndexMap;
use shirabe_php_shim::{
- CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, preg_match2,
- preg_replace, preg_split, version_compare,
+ CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, preg_match, preg_replace,
+ preg_split, version_compare,
};
#[derive(Debug)]
@@ -353,8 +353,8 @@ impl VcsDownloader for SvnDownloader {
to_reference: &str,
path: &str,
) -> anyhow::Result<String> {
- if preg_match2(php_regex!(r"{@(\d+)$}"), from_reference, 0).is_some()
- && preg_match2(php_regex!(r"{@(\d+)$}"), to_reference, 0).is_some()
+ if preg_match(php_regex!(r"{@(\d+)$}"), from_reference).is_some()
+ && preg_match(php_regex!(r"{@(\d+)$}"), to_reference).is_some()
{
// retrieve the svn base url from the checkout folder
let command = vec![
@@ -382,7 +382,7 @@ impl VcsDownloader for SvnDownloader {
}
let url_pattern = "#<url>(.*)</url>#";
- let base_url = if let Some(matches) = preg_match2(url_pattern, &output, 0) {
+ let base_url = if let Some(matches) = preg_match(url_pattern, &output) {
matches.get(1).unwrap_or_default().to_string()
} else {
return Err(RuntimeException::new(format!(
@@ -453,7 +453,7 @@ impl ChangeReportInterface for SvnDownloader {
);
Ok(
- if preg_match2(php_regex!("{^ *[^X ] +}m"), &output, 0).is_some() {
+ if preg_match(php_regex!("{^ *[^X ] +}m"), &output).is_some() {
Some(output)
} else {
None
diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs
index 7b0ad050..565005d9 100644
--- a/crates/shirabe/src/downloader/zip_downloader.rs
+++ b/crates/shirabe/src/downloader/zip_downloader.rs
@@ -12,7 +12,7 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
CmpOp, ErrorException, PhpMixed, RuntimeException, UnexpectedValueException, ZipArchive,
bin2hex, class_exists, file_exists, file_get_contents, filesize, function_exists, hash_file,
- impl_php_class, is_file, json_encode, php_regex, preg_match2, random_int, str_replace, strlen,
+ impl_php_class, is_file, json_encode, php_regex, preg_match, random_int, str_replace, strlen,
substr, version_compare,
};
use shirabe_symfony_process::ExecutableFinder;
@@ -112,11 +112,8 @@ impl ZipDownloader {
.execute(&[command_spec[1].as_str()], &mut output, None::<&str>)
.unwrap_or(1)
== 0
- && let Some(m) = preg_match2(
- php_regex!(r"{^\s*7-Zip(?:\s\[64\])?\s([0-9.]+)}"),
- &output,
- 0,
- )
+ && let Some(m) =
+ preg_match(php_regex!(r"{^\s*7-Zip(?:\s\[64\])?\s([0-9.]+)}"), &output)
{
let m1 = m.get(1).unwrap_or_default().to_string();
if version_compare(&m1, "21.01", CmpOp::Lt) {