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/composer_repository.rs20
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs108
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs12
-rw-r--r--crates/shirabe/src/repository/vcs/git_driver.rs14
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs67
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs63
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs34
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs55
9 files changed, 106 insertions, 271 deletions
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index d42a9778..8970a227 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -37,7 +37,7 @@ use futures::StreamExt;
use futures::stream::FuturesOrdered;
use indexmap::IndexMap;
use shirabe_metadata_minifier::MetadataMinifier;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
AnyThrowable, CmpOp, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed,
@@ -250,7 +250,7 @@ impl ComposerRepository {
&url,
) {
let proto = match_packagist
- .get(&CaptureKey::ByName("proto".to_string()))
+ .name("proto")
.unwrap_or_default()
.to_string();
url = format!("{}://repo.packagist.org", proto);
@@ -784,14 +784,8 @@ impl ComposerRepository {
&query,
) && let Some(list_url) = self.list_url.as_ref()
{
- let q = match_groups
- .get(&CaptureKey::ByName("query".to_string()))
- .unwrap_or_default()
- .to_string();
- let vendor = match_groups
- .get(&CaptureKey::ByName("vendor".to_string()))
- .unwrap_or_default()
- .to_string();
+ let q = match_groups.name("query").unwrap_or_default().to_string();
+ let vendor = match_groups.name("vendor").unwrap_or_default().to_string();
let url = format!(
"{}?vendor={}&filter={}",
list_url,
@@ -2427,11 +2421,7 @@ impl ComposerRepository {
if url.starts_with('/') {
if let Some(matches) = Preg::is_match3(php_regex!(r"{^[^:]++://[^/]*+}"), &self.url) {
- return Ok(format!(
- "{}{}",
- matches.get(&CaptureKey::ByIndex(0)).unwrap_or_default(),
- url
- ));
+ return Ok(format!("{}{}", matches.get(0).unwrap_or_default(), url));
}
return Ok(self.url.clone());
diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs
index 94ecc015..3df346de 100644
--- a/crates/shirabe/src/repository/platform_repository.rs
+++ b/crates/shirabe/src/repository/platform_repository.rs
@@ -16,7 +16,7 @@ use crate::plugin::plugin_interface::{self};
use crate::repository::ArrayRepository;
use crate::repository::RepositoryInterface;
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_rpc::PlatformInfo;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn,
@@ -323,7 +323,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-librabbitmq", name),
- librabbitmq_matches.get(&CaptureKey::ByName("version".to_string())),
+ librabbitmq_matches.name("version"),
Some("AMQP librabbitmq version"),
&[],
&[],
@@ -336,7 +336,7 @@ impl PlatformRepository {
info,
) {
let version_str = protocol_matches
- .get(&CaptureKey::ByName("version".to_string()))
+ .name("version")
.unwrap_or_default()
.to_string();
self.add_library(
@@ -360,7 +360,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
name,
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
None,
&[],
&[],
@@ -386,14 +386,10 @@ impl PlatformRepository {
php_regex!("{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im"),
info,
) {
- let ssl_library_raw = ssl_matches
- .get(&CaptureKey::ByName("library".to_string()))
- .unwrap_or_default()
- .to_string();
- let ssl_version = ssl_matches
- .get(&CaptureKey::ByName("version".to_string()))
- .unwrap_or_default()
- .to_string();
+ let ssl_library_raw =
+ ssl_matches.name("library").unwrap_or_default().to_string();
+ let ssl_version =
+ ssl_matches.name("version").unwrap_or_default().to_string();
let library = strtolower(&ssl_library_raw);
if library == "openssl" {
let mut is_fips = false;
@@ -421,7 +417,7 @@ impl PlatformRepository {
) {
shortlib = "securetransport".to_string();
let m1 = securetransport_matches
- .get(&CaptureKey::ByIndex(1))
+ .get(1)
.unwrap_or_default()
.to_string();
ssl_lib = format!("curl-{}", m1);
@@ -451,14 +447,10 @@ impl PlatformRepository {
),
info,
) {
- let ssh_library = ssh_matches
- .get(&CaptureKey::ByName("library".to_string()))
- .unwrap_or_default()
- .to_string();
- let ssh_version = ssh_matches
- .get(&CaptureKey::ByName("version".to_string()))
- .unwrap_or_default()
- .to_string();
+ let ssh_library =
+ ssh_matches.name("library").unwrap_or_default().to_string();
+ let ssh_version =
+ ssh_matches.name("version").unwrap_or_default().to_string();
self.add_library(
&mut libraries,
&format!("{}-{}", name, strtolower(&ssh_library)),
@@ -476,7 +468,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-zlib", name),
- zlib_matches.get(&CaptureKey::ByName("version".to_string())),
+ zlib_matches.name("version"),
Some("curl zlib version"),
&[],
&[],
@@ -494,7 +486,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-timelib", name),
- timelib_matches.get(&CaptureKey::ByName("version".to_string())),
+ timelib_matches.name("version"),
Some("date timelib version"),
&[],
&[],
@@ -507,7 +499,7 @@ impl PlatformRepository {
info,
) {
let external = zoneinfo_source_matches
- .get(&CaptureKey::ByName("source".to_string()))
+ .name("source")
.map(|s| s == "external")
.unwrap_or(false);
if let Some(zoneinfo_matches) = Preg::is_match3(
@@ -517,7 +509,7 @@ impl PlatformRepository {
info,
) {
let zoneinfo_version = zoneinfo_matches
- .get(&CaptureKey::ByName("version".to_string()))
+ .name("version")
.unwrap_or_default()
.to_string();
// If the timezonedb is provided by ext/timezonedb, register that version as a replacement
@@ -556,7 +548,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libmagic", name),
- magic_matches.get(&CaptureKey::ByName("version".to_string())),
+ magic_matches.name("version"),
Some("fileinfo libmagic version"),
&[],
&[],
@@ -586,7 +578,7 @@ impl PlatformRepository {
info,
) {
let libjpeg_version = libjpeg_matches
- .get(&CaptureKey::ByName("version".to_string()))
+ .name("version")
.unwrap_or_default()
.to_string();
let parsed = Version::parse_libjpeg(&libjpeg_version).unwrap_or_default();
@@ -606,7 +598,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libpng", name),
- libpng_matches.get(&CaptureKey::ByName("version".to_string())),
+ libpng_matches.name("version"),
Some("libpng version for gd"),
&[],
&[],
@@ -620,7 +612,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-freetype", name),
- freetype_matches.get(&CaptureKey::ByName("version".to_string())),
+ freetype_matches.name("version"),
Some("freetype version for gd"),
&[],
&[],
@@ -632,7 +624,7 @@ impl PlatformRepository {
info,
) {
let version_id: i64 = libxpm_matches
- .get(&CaptureKey::ByName("versionId".to_string()))
+ .name("versionId")
.and_then(|s| s.parse().ok())
.unwrap_or(0);
let converted = Version::convert_libxpm_version_id(version_id);
@@ -705,7 +697,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
"icu",
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
Some(description),
&[],
&[],
@@ -719,7 +711,7 @@ impl PlatformRepository {
info,
) {
let zi_version = zoneinfo_matches
- .get(&CaptureKey::ByName("version".to_string()))
+ .name("version")
.unwrap_or_default()
.to_string();
if let Some(parsed) = Version::parse_zoneinfo_version(&zi_version) {
@@ -781,11 +773,9 @@ impl PlatformRepository {
php_regex!("/^ImageMagick (?<version>[\\d.]+)(?:-(?<patch>\\d+))?/"),
&image_magick_version_str,
) {
- let mut version_built = matches
- .get(&CaptureKey::ByName("version".to_string()))
- .unwrap_or_default()
- .to_string();
- if let Some(patch) = matches.get(&CaptureKey::ByName("patch".to_string())) {
+ let mut version_built =
+ matches.name("version").unwrap_or_default().to_string();
+ if let Some(patch) = matches.name("patch") {
version_built = format!("{}.{}", version_built, patch);
}
@@ -810,12 +800,12 @@ impl PlatformRepository {
Preg::is_match3(php_regex!("/^Vendor Name => (?<vendor>.+)$/im"), info)
{
let version_id: i64 = matches
- .get(&CaptureKey::ByName("versionId".to_string()))
+ .name("versionId")
.and_then(|s| s.parse().ok())
.unwrap_or(0);
let converted = Version::convert_openldap_version_id(version_id);
let vendor = vendor_matches
- .get(&CaptureKey::ByName("vendor".to_string()))
+ .name("vendor")
.unwrap_or_default()
.to_string();
self.add_library(
@@ -864,7 +854,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libmbfl", name),
- libmbfl_matches.get(&CaptureKey::ByName("version".to_string())),
+ libmbfl_matches.name("version"),
Some("mbstring libmbfl version"),
&[],
&[],
@@ -898,7 +888,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-oniguruma", name),
- oniguruma_matches.get(&CaptureKey::ByName("version".to_string())),
+ oniguruma_matches.name("version"),
Some("mbstring oniguruma version"),
&[],
&[],
@@ -918,7 +908,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libmemcached", name),
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
Some("libmemcached version"),
&[],
&[],
@@ -937,10 +927,7 @@ impl PlatformRepository {
php_regex!("{^(?:OpenSSL|LibreSSL)?\\s*(?<version>\\S+)}i"),
&openssl_text_str,
) {
- let version = matches
- .get(&CaptureKey::ByName("version".to_string()))
- .unwrap_or_default()
- .to_string();
+ let version = matches.name("version").unwrap_or_default().to_string();
let mut is_fips = false;
let parsed_version =
Version::parse_openssl(&version, &mut is_fips).unwrap_or_default();
@@ -979,7 +966,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-unicode", name),
- pcre_unicode_matches.get(&CaptureKey::ByName("version".to_string())),
+ pcre_unicode_matches.name("version"),
Some("PCRE Unicode version support"),
&[],
&[],
@@ -999,7 +986,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-mysqlnd", name),
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
Some(&format!("mysqlnd library version for {}", name)),
&[],
&[],
@@ -1017,7 +1004,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libmongoc", name),
- libmongoc_matches.get(&CaptureKey::ByName("version".to_string())),
+ libmongoc_matches.name("version"),
Some("libmongoc version of mongodb"),
&[],
&[],
@@ -1031,7 +1018,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libbson", name),
- libbson_matches.get(&CaptureKey::ByName("version".to_string())),
+ libbson_matches.name("version"),
Some("libbson version of mongodb"),
&[],
&[],
@@ -1065,7 +1052,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libpq", name),
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
Some(&format!("libpq for {}", name)),
&[],
&[],
@@ -1084,7 +1071,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libpq", name),
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
Some(&format!("libpq for {}", name)),
&[],
&[],
@@ -1104,7 +1091,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libpq", name),
- matches.get(&CaptureKey::ByName("linked".to_string())),
+ matches.name("linked"),
Some(&format!("libpq for {}", name)),
&[],
&[],
@@ -1177,7 +1164,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-sqlite", name),
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
None,
&[],
&[],
@@ -1194,7 +1181,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libssh2", name),
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
None,
&[],
&[],
@@ -1228,7 +1215,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
"libxslt-libxml",
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
Some("libxml version libxslt is compiled against"),
&[],
&[],
@@ -1245,7 +1232,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
&format!("{}-libyaml", name),
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
Some("libyaml version of yaml"),
&[],
&[],
@@ -1298,7 +1285,7 @@ impl PlatformRepository {
self.add_library(
&mut libraries,
name,
- matches.get(&CaptureKey::ByName("version".to_string())),
+ matches.name("version"),
None,
&[],
&[],
@@ -1494,10 +1481,7 @@ impl PlatformRepository {
php_regex!("{^(\\d+\\.\\d+\\.\\d+(?:\\.\\d+)?)}"),
&pretty_version,
) {
- pretty_version = m
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string();
+ pretty_version = m.get(1).unwrap_or_default().to_string();
} else {
pretty_version = "0".to_string();
}
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 8aa72a6c..8047602a 100644
--- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs
+++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
@@ -15,7 +15,7 @@ use crate::util::ForgejoRepositoryData;
use crate::util::ForgejoUrl;
use crate::util::http::Response;
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, php_regex, urlencode,
@@ -585,7 +585,7 @@ impl ForgejoDriver {
let links = explode(",", &header);
for link in links {
if let Some(m) = Preg::match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), &link)
- && let Some(url) = m.get(&CaptureKey::ByIndex(1))
+ && let Some(url) = m.get(1)
{
return Some(url.to_string());
}
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index e053cadf..5f83b4e1 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -15,7 +15,7 @@ use crate::util::Bitbucket;
use crate::util::http::Response;
use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
@@ -95,14 +95,8 @@ impl GitBitbucketDriver {
.into());
};
- self.owner = m
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string();
- self.repository = m
- .get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string();
+ self.owner = m.get(1).unwrap_or_default().to_string();
+ self.repository = m.get(2).unwrap_or_default().to_string();
self.inner.origin_url = "bitbucket.org".to_string();
self.inner.cache = Some(Cache::new(
self.inner.io.clone(),
diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs
index bd56766b..c224e8e6 100644
--- a/crates/shirabe/src/repository/vcs/git_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_driver.rs
@@ -14,7 +14,7 @@ use crate::util::Url;
use chrono::TimeZone;
use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath,
@@ -200,7 +200,7 @@ impl GitDriver {
for branch in &branches {
if !branch.is_empty()
&& let Some(caps) = Preg::match3(php_regex!(r"{^\* +(\S+)}"), branch)
- && let Some(name) = caps.get(&CaptureKey::ByIndex(1))
+ && let Some(name) = caps.get(1)
{
self.root_identifier = Some(name.to_string());
break;
@@ -313,10 +313,7 @@ impl GitDriver {
php_regex!(r"{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}"),
&tag,
)
- && let (Some(hash), Some(name)) = (
- caps.get(&CaptureKey::ByIndex(1)),
- caps.get(&CaptureKey::ByIndex(2)),
- )
+ && let (Some(hash), Some(name)) = (caps.get(1), caps.get(2))
{
self.tags
.as_mut()
@@ -352,10 +349,7 @@ impl GitDriver {
php_regex!(r"{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}"),
&branch,
)
- && let (Some(name), Some(hash)) = (
- caps.get(&CaptureKey::ByIndex(1)),
- caps.get(&CaptureKey::ByIndex(2)),
- )
+ && let (Some(name), Some(hash)) = (caps.get(1), caps.get(2))
&& !name.starts_with('-')
{
branches.insert(name.to_string(), hash.to_string());
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 08561171..11bb9503 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -14,7 +14,7 @@ use crate::util::GitHub;
use crate::util::http::Response;
use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_map,
@@ -83,25 +83,14 @@ impl GitHubDriver {
.into());
};
- self.owner = match_
- .get(&CaptureKey::ByIndex(3))
- .unwrap_or_default()
- .to_string();
- self.repository = match_
- .get(&CaptureKey::ByIndex(4))
- .unwrap_or_default()
- .to_string();
+ self.owner = match_.get(3).unwrap_or_default().to_string();
+ self.repository = match_.get(4).unwrap_or_default().to_string();
self.inner.origin_url = strtolower(
&match_
- .get(&CaptureKey::ByIndex(1))
+ .get(1)
.filter(|s| !s.is_empty())
.map(str::to_string)
- .unwrap_or_else(|| {
- match_
- .get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string()
- }),
+ .unwrap_or_else(|| match_.get(2).unwrap_or_default().to_string()),
);
if self.inner.origin_url == "www.github.com" {
self.inner.origin_url = "github.com".to_string();
@@ -494,23 +483,14 @@ impl GitHubDriver {
for line in preg_split(php_regex!(r"{\r?\n}"), &funding) {
let line = trim(&line, None);
if let Some(m) = Preg::is_match3(php_regex!(r"{^(\w+)\s*:\s*(.+)$}"), &line) {
- let g1 = m
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string();
- let g2 = m
- .get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string();
+ let g1 = m.get(1).unwrap_or_default().to_string();
+ let g2 = m.get(2).unwrap_or_default().to_string();
if g2 == "[" {
key = Some(g1);
continue;
}
if let Some(m2) = Preg::is_match3(php_regex!(r"{^\[(.*?)\](?:\s*#.*)?$}"), &g2) {
- let inner = m2
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string();
+ let inner = m2.get(1).unwrap_or_default().to_string();
for item in array_map(
|s: &String| trim(s, None),
&preg_split(php_regex!(r#"{[\'\"]?\s*,\s*[\'\"]?}"#), &inner),
@@ -530,20 +510,13 @@ impl GitHubDriver {
entry.insert("type".to_string(), PhpMixed::String(g1.clone()));
entry.insert(
"url".to_string(),
- PhpMixed::String(trim(
- m2.get(&CaptureKey::ByIndex(1)).unwrap_or_default(),
- Some("\"' "),
- )),
+ PhpMixed::String(trim(m2.get(1).unwrap_or_default(), Some("\"' "))),
);
result.push(entry);
}
key = None;
} else if let Some(m) = Preg::is_match3(php_regex!(r"{^(\w+)\s*:\s*#\s*$}"), &line) {
- key = Some(
- m.get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string(),
- );
+ key = Some(m.get(1).unwrap_or_default().to_string());
} else if key.is_some()
&& let Some(m) = Preg::is_match3(php_regex!(r"{^-\s*(.+)(?:\s+#.*)?$}"), &line)
.or_else(|| Preg::is_match3(php_regex!(r"{^(.+),(?:\s*#.*)?$}"), &line))
@@ -555,10 +528,7 @@ impl GitHubDriver {
);
entry.insert(
"url".to_string(),
- PhpMixed::String(trim(
- m.get(&CaptureKey::ByIndex(1)).unwrap_or_default(),
- Some("\"' "),
- )),
+ PhpMixed::String(trim(m.get(1).unwrap_or_default(), Some("\"' "))),
);
result.push(entry);
} else if key.is_some() && line == "]" {
@@ -948,15 +918,10 @@ impl GitHubDriver {
};
let origin_url = matches
- .get(&CaptureKey::ByIndex(2))
+ .get(2)
.filter(|s| !s.is_empty())
.map(str::to_string)
- .unwrap_or_else(|| {
- matches
- .get(&CaptureKey::ByIndex(3))
- .unwrap_or_default()
- .to_string()
- });
+ .unwrap_or_else(|| matches.get(3).unwrap_or_default().to_string());
if !in_array_loose(
strtolower(&Preg::replace(php_regex!(r"{^www\.}i"), "", &origin_url)),
config.borrow().get("github-domains").values(),
@@ -1285,11 +1250,7 @@ impl GitHubDriver {
let links = explode(",", &header);
for link in &links {
if let Some(m) = Preg::is_match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), link) {
- return Some(
- m.get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string(),
- );
+ return Some(m.get(1).unwrap_or_default().to_string());
}
}
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index 5494feed..30c3f7ae 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -15,7 +15,7 @@ use crate::util::HttpDownloader;
use crate::util::http::Response;
use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
@@ -90,27 +90,14 @@ impl GitLabDriver {
};
let guessed_domain = match_
- .get(&CaptureKey::ByName("domain".to_string()))
+ .name("domain")
.filter(|s| !s.is_empty())
.map(str::to_string)
- .unwrap_or_else(|| {
- match_
- .get(&CaptureKey::ByName("domain2".to_string()))
- .unwrap_or_default()
- .to_string()
- });
+ .unwrap_or_else(|| match_.name("domain2").unwrap_or_default().to_string());
let configured_domains = self.inner.config.borrow_mut().get("gitlab-domains");
- let mut url_parts: Vec<String> = explode(
- "/",
- match_
- .get(&CaptureKey::ByName("parts".to_string()))
- .unwrap_or_default(),
- );
+ let mut url_parts: Vec<String> = explode("/", match_.name("parts").unwrap_or_default());
- let scheme_match = match_
- .get(&CaptureKey::ByName("scheme".to_string()))
- .unwrap_or_default()
- .to_string();
+ let scheme_match = match_.name("scheme").unwrap_or_default().to_string();
self.scheme = if matches!(scheme_match.as_str(), "https" | "http") {
scheme_match
} else if self
@@ -124,9 +111,7 @@ impl GitLabDriver {
} else {
"https".to_string()
};
- let port = match_
- .get(&CaptureKey::ByName("port".to_string()))
- .map(str::to_string);
+ let port = match_.name("port").map(str::to_string);
let origin =
Self::determine_origin(&configured_domains, guessed_domain, &mut url_parts, port);
let origin = match origin {
@@ -170,9 +155,7 @@ impl GitLabDriver {
self.repository = Preg::replace(
php_regex!(r"#(\.git)$#"),
"",
- match_
- .get(&CaptureKey::ByName("repo".to_string()))
- .unwrap_or_default(),
+ match_.name("repo").unwrap_or_default(),
);
self.inner.cache = Some(Cache::new(
@@ -948,34 +931,19 @@ impl GitLabDriver {
return Ok(false);
};
- let scheme = match_
- .get(&CaptureKey::ByName("scheme".to_string()))
- .unwrap_or_default()
- .to_string();
+ let scheme = match_.name("scheme").unwrap_or_default().to_string();
let guessed_domain = match_
- .get(&CaptureKey::ByName("domain".to_string()))
+ .name("domain")
.filter(|s| !s.is_empty())
.map(str::to_string)
- .unwrap_or_else(|| {
- match_
- .get(&CaptureKey::ByName("domain2".to_string()))
- .unwrap_or_default()
- .to_string()
- });
- let mut url_parts: Vec<String> = explode(
- "/",
- match_
- .get(&CaptureKey::ByName("parts".to_string()))
- .unwrap_or_default(),
- );
+ .unwrap_or_else(|| match_.name("domain2").unwrap_or_default().to_string());
+ let mut url_parts: Vec<String> = explode("/", match_.name("parts").unwrap_or_default());
if Self::determine_origin(
&config.borrow().get("gitlab-domains"),
guessed_domain,
&mut url_parts,
- match_
- .get(&CaptureKey::ByName("port".to_string()))
- .map(str::to_string),
+ match_.name("port").map(str::to_string),
)
.is_none()
{
@@ -1011,12 +979,7 @@ impl GitLabDriver {
let links = explode(",", &header);
for link in &links {
if let Some(match_) = Preg::is_match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), link) {
- return Some(
- match_
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string(),
- );
+ return Some(match_.get(1).unwrap_or_default().to_string());
}
}
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index aae9c7cb..120b8ea8 100644
--- a/crates/shirabe/src/repository/vcs/hg_driver.rs
+++ b/crates/shirabe/src/repository/vcs/hg_driver.rs
@@ -11,7 +11,7 @@ use crate::util::Hg as HgUtils;
use crate::util::Url;
use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable, php_regex};
@@ -236,12 +236,8 @@ impl HgDriver {
&& let Some(m) = Preg::match3(php_regex!(r"(^([^\s]+)\s+\d+:(.*)$)"), &tag)
{
tags.insert(
- m.get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string(),
- m.get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string(),
+ m.get(1).unwrap_or_default().to_string(),
+ m.get(2).unwrap_or_default().to_string(),
);
}
}
@@ -269,17 +265,9 @@ impl HgDriver {
&& let Some(m) =
Preg::match3(php_regex!(r"(^([^\s]+)\s+\d+:([a-f0-9]+))"), &branch)
{
- let name = m
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string();
+ let name = m.get(1).unwrap_or_default().to_string();
if !name.starts_with('-') {
- branches.insert(
- name,
- m.get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string(),
- );
+ branches.insert(name, m.get(2).unwrap_or_default().to_string());
}
}
}
@@ -295,17 +283,9 @@ impl HgDriver {
&& let Some(m) =
Preg::match3(php_regex!(r"(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)"), &branch)
{
- let name = m
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string();
+ let name = m.get(1).unwrap_or_default().to_string();
if !name.starts_with('-') {
- bookmarks.insert(
- name,
- m.get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string(),
- );
+ bookmarks.insert(name, m.get(2).unwrap_or_default().to_string());
}
}
}
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index bdd7f021..6fb987a4 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -13,7 +13,7 @@ use crate::util::Svn as SvnUtil;
use crate::util::Url;
use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::Preg;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
PhpMixed, RuntimeException, php_regex, stripos, strrpos, strtr, substr, trim,
@@ -259,14 +259,9 @@ impl SvnDriver {
let (path, rev) = if let Some(m) =
Preg::is_match3(php_regex!(r"{^(.+?)(@\d+)?/$}"), &identifier)
- && let Some(rev) = m.get(&CaptureKey::ByIndex(2))
+ && let Some(rev) = m.get(2)
{
- (
- m.get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string(),
- rev.to_string(),
- )
+ (m.get(1).unwrap_or_default().to_string(), rev.to_string())
} else {
(identifier, String::new())
};
@@ -298,14 +293,9 @@ impl SvnDriver {
let (path, rev) = if let Some(m) =
Preg::is_match3(php_regex!(r"{^(.+?)(@\d+)?/$}"), &identifier)
- && let Some(rev) = m.get(&CaptureKey::ByIndex(2))
+ && let Some(rev) = m.get(2)
{
- (
- m.get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string(),
- rev.to_string(),
- )
+ (m.get(1).unwrap_or_default().to_string(), rev.to_string())
} else {
(identifier, String::new())
};
@@ -319,10 +309,7 @@ impl SvnDriver {
&& let Some(m) =
Preg::is_match3(php_regex!(r"{^Last Changed Date: ([^(]+)}"), &line)
{
- let date_str = m
- .get(&CaptureKey::ByIndex(1))
- .unwrap_or_default()
- .to_string();
+ let date_str = m.get(1).unwrap_or_default().to_string();
return Ok(shirabe_php_shim::date_create::<Utc>(date_str.trim())
.ok()
.map(|d| d.fixed_offset()));
@@ -350,14 +337,8 @@ impl SvnDriver {
&& let Some(m) =
Preg::is_match3(php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"), &line)
{
- let rev: i64 = m
- .get(&CaptureKey::ByIndex(1))
- .and_then(|s| s.parse().ok())
- .unwrap_or(0);
- let path = m
- .get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string();
+ let rev: i64 = m.get(1).and_then(|s| s.parse().ok()).unwrap_or(0);
+ let path = m.get(2).unwrap_or_default().to_string();
if path == "./" {
last_rev = rev;
} else {
@@ -399,14 +380,8 @@ impl SvnDriver {
&& let Some(m) =
Preg::is_match3(php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"), &line)
{
- let rev: i64 = m
- .get(&CaptureKey::ByIndex(1))
- .and_then(|s| s.parse().ok())
- .unwrap_or(0);
- let path = m
- .get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string();
+ let rev: i64 = m.get(1).and_then(|s| s.parse().ok()).unwrap_or(0);
+ let path = m.get(2).unwrap_or_default().to_string();
if path == "./" {
let identifier = self.build_identifier(
&format!("/{}", self.trunk_path.clone().unwrap_or_default()),
@@ -440,14 +415,8 @@ impl SvnDriver {
&& let Some(m) =
Preg::is_match3(php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"), &line)
{
- let rev: i64 = m
- .get(&CaptureKey::ByIndex(1))
- .and_then(|s| s.parse().ok())
- .unwrap_or(0);
- let path = m
- .get(&CaptureKey::ByIndex(2))
- .unwrap_or_default()
- .to_string();
+ let rev: i64 = m.get(1).and_then(|s| s.parse().ok()).unwrap_or(0);
+ let path = m.get(2).unwrap_or_default().to_string();
if path == "./" {
last_rev = rev;
} else {