aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-17 06:43:52 +0900
committernsfisis <nsfisis@gmail.com>2026-08-17 06:43:52 +0900
commit52a0665acbbe5bf5b8c6875118fb9cdf7952453b (patch)
tree7302b0b87f7b0d406126da734ef82c80abf64204 /crates/shirabe/src/repository
parentc81e9f89d9e4388f36a4427bbaa95eced659d2ce (diff)
downloadphp-shirabe-52a0665acbbe5bf5b8c6875118fb9cdf7952453b.tar.gz
php-shirabe-52a0665acbbe5bf5b8c6875118fb9cdf7952453b.tar.zst
php-shirabe-52a0665acbbe5bf5b8c6875118fb9cdf7952453b.zip
refactor(preg): wrap the preg_* $matches maps in newtypes
The five IndexMap shapes that the preg_* functions and Preg fill in are now distinct types generated by preg_match_map!, so a matches map no longer interchanges with any other map of the same key and value type. Index<usize> is kept alongside Index<&Q> because call sites such as config_command and event_dispatcher reach for a group by its position in the map rather than by its capture key.
Diffstat (limited to 'crates/shirabe/src/repository')
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs8
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs77
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/git_driver.rs8
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs14
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs8
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs8
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs10
9 files changed, 70 insertions, 71 deletions
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index 5f9314b4..33703709 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
AnyThrowable, CmpOp, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed,
@@ -245,7 +245,7 @@ impl ComposerRepository {
.to_string();
// force url for packagist.org to repo.packagist.org
- let mut match_packagist: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut match_packagist = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r"{^(?P<proto>https?)://packagist\.org/?$}i"),
&url,
@@ -781,7 +781,7 @@ impl ComposerRepository {
if self.has_providers()? || self.lazy_providers_url.is_some() {
// optimize search for "^foo/bar" where at least "^foo/" is present by loading this directly from the listUrl if present
- let mut match_groups: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut match_groups = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r"{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i"),
&query,
@@ -2430,7 +2430,7 @@ impl ComposerRepository {
}
if url.starts_with('/') {
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r"{^[^:]++://[^/]*+}"),
&self.url,
diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs
index 7c7030f0..6c25d967 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_rpc::PlatformInfo;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn,
@@ -316,7 +316,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// librabbitmq version => 0.9.0
- let mut librabbitmq_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut librabbitmq_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^librabbitmq version => (?<version>.+)$/im"),
info,
@@ -335,7 +335,7 @@ impl PlatformRepository {
}
// AMQP protocol version => 0-9-1
- let mut protocol_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut protocol_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^AMQP protocol version => (?<version>.+)$/im"),
info,
@@ -360,7 +360,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// BZip2 Version => 1.0.6, 6-Sept-2010
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^BZip2 Version => (?<version>.*),/im"),
info,
@@ -393,7 +393,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// SSL Version => OpenSSL/1.0.1t
- let mut ssl_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut ssl_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im"),
info,
@@ -428,8 +428,7 @@ impl PlatformRepository {
} else {
let (shortlib, ssl_lib);
if library.starts_with("(securetransport)") {
- let mut securetransport_matches: IndexMap<CaptureKey, String> =
- IndexMap::new();
+ let mut securetransport_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("{^\\(securetransport\\) ([a-z0-9]+)}"),
&library,
@@ -461,7 +460,7 @@ impl PlatformRepository {
}
// libSSH Version => libssh2/1.4.3
- let mut ssh_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut ssh_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(
"{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im"
@@ -488,7 +487,7 @@ impl PlatformRepository {
}
// ZLib Version => 1.2.8
- let mut zlib_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut zlib_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("{^ZLib Version => (?<version>.+)$}im"),
info,
@@ -511,7 +510,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// timelib version => 2018.03
- let mut timelib_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut timelib_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^timelib version => (?<version>.+)$/im"),
info,
@@ -530,7 +529,7 @@ impl PlatformRepository {
}
// Timezone Database => internal
- let mut zoneinfo_source_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut zoneinfo_source_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^Timezone Database => (?<source>internal|external)$/im"),
info,
@@ -540,7 +539,7 @@ impl PlatformRepository {
.get(&CaptureKey::ByName("source".to_string()))
.map(|s| s == "external")
.unwrap_or(false);
- let mut zoneinfo_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut zoneinfo_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(
"/^\"Olson\" Timezone Database Version => (?<version>.+?)(?:\\.system)?$/im"
@@ -582,7 +581,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// libmagic => 537
- let mut magic_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut magic_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libmagic => (?<version>.+)$/im"),
info,
@@ -618,7 +617,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
- let mut libjpeg_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut libjpeg_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im"),
info,
@@ -639,7 +638,7 @@ impl PlatformRepository {
)?;
}
- let mut libpng_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut libpng_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libPNG Version => (?<version>.+)$/im"),
info,
@@ -657,7 +656,7 @@ impl PlatformRepository {
)?;
}
- let mut freetype_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut freetype_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^FreeType Version => (?<version>.+)$/im"),
info,
@@ -675,7 +674,7 @@ impl PlatformRepository {
)?;
}
- let mut libxpm_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut libxpm_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libXpm Version => (?<versionId>\\d+)$/im"),
info,
@@ -749,7 +748,7 @@ impl PlatformRepository {
&[],
)?;
} else {
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^ICU version => (?<version>.+)$/im"),
info,
@@ -769,7 +768,7 @@ impl PlatformRepository {
}
// ICU TZData version => 2019c
- let mut zoneinfo_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut zoneinfo_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^ICU TZData version => (?<version>.*)$/im"),
info,
@@ -834,7 +833,7 @@ impl PlatformRepository {
Self::imagick_get_version_string(image_magick_version);
// 6.x: ImageMagick 6.2.9 08/24/06 Q16 http://www.imagemagick.org
// 7.x: ImageMagick 7.0.8-34 Q16 x86_64 2019-03-23 https://imagemagick.org
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^ImageMagick (?<version>[\\d.]+)(?:-(?<patch>\\d+))?/"),
&image_magick_version_str,
@@ -862,8 +861,8 @@ impl PlatformRepository {
"ldap" => {
let info = platform_info.get_extension_info(name);
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- let mut vendor_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
+ let mut vendor_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^Vendor Version => (?<versionId>\\d+)$/im"),
info,
@@ -922,7 +921,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// libmbfl version => 1.3.2
- let mut libmbfl_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut libmbfl_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libmbfl version => (?<version>.+)$/im"),
info,
@@ -958,7 +957,7 @@ impl PlatformRepository {
// Multibyte regex (oniguruma) version => 5.9.5
// oniguruma version => 6.9.0
} else {
- let mut oniguruma_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut oniguruma_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(
"/^(?:oniguruma|Multibyte regex \\(oniguruma\\)) version => (?<version>.+)$/im"
@@ -984,7 +983,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// libmemcached version => 1.0.18
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libmemcached version => (?<version>.+)$/im"),
info,
@@ -1010,7 +1009,7 @@ impl PlatformRepository {
_ => "".to_string(),
};
// OpenSSL 1.1.1g 21 Apr 2020
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("{^(?:OpenSSL|LibreSSL)?\\s*(?<version>\\S+)}i"),
&openssl_text_str,
@@ -1051,7 +1050,7 @@ impl PlatformRepository {
let info = platform_info.get_extension_info(name);
// PCRE Unicode Version => 12.1.0
- let mut pcre_unicode_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut pcre_unicode_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^PCRE Unicode Version => (?<version>.+)$/im"),
info,
@@ -1073,7 +1072,7 @@ impl PlatformRepository {
"mysqlnd" | "pdo_mysql" => {
let info = platform_info.get_extension_info(name);
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(
"/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi"
@@ -1097,7 +1096,7 @@ impl PlatformRepository {
"mongodb" => {
let info = platform_info.get_extension_info(name);
- let mut libmongoc_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut libmongoc_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libmongoc bundled version => (?<version>.+)$/im"),
info,
@@ -1115,7 +1114,7 @@ impl PlatformRepository {
)?;
}
- let mut libbson_matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut libbson_matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libbson bundled version => (?<version>.+)$/im"),
info,
@@ -1153,7 +1152,7 @@ impl PlatformRepository {
// intentional fall-through to next case...
let info = platform_info.get_extension_info(name);
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^PostgreSQL\\(libpq\\) Version => (?<version>.*)$/im"),
info,
@@ -1176,7 +1175,7 @@ impl PlatformRepository {
"pdo_pgsql" => {
let info = platform_info.get_extension_info(name);
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^PostgreSQL\\(libpq\\) Version => (?<version>.*)$/im"),
info,
@@ -1200,7 +1199,7 @@ impl PlatformRepository {
// Used Library => Compiled => Linked
// libpq => 14.3 (Ubuntu 14.3-1.pgdg22.04+1) => 15.0.2
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libpq => (?<compiled>.+) => (?<linked>.+)$/im"),
info,
@@ -1278,7 +1277,7 @@ impl PlatformRepository {
"sqlite3" | "pdo_sqlite" => {
let info = platform_info.get_extension_info(name);
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^SQLite Library => (?<version>.+)$/im"),
info,
@@ -1300,7 +1299,7 @@ impl PlatformRepository {
"ssh2" => {
let info = platform_info.get_extension_info(name);
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^libssh2 version => (?<version>.+)$/im"),
info,
@@ -1336,7 +1335,7 @@ impl PlatformRepository {
)?;
let info = platform_info.get_extension_info("xsl");
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(
"/^libxslt compiled against libxml Version => (?<version>.+)$/im"
@@ -1360,7 +1359,7 @@ impl PlatformRepository {
"yaml" => {
let info = platform_info.get_extension_info("yaml");
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^LibYAML Version => (?<version>.+)$/im"),
info,
@@ -1417,7 +1416,7 @@ impl PlatformRepository {
// Linked Version => 1.2.8
} else {
let info = platform_info.get_extension_info(name);
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^Linked Version => (?<version>.+)$/im"),
info,
@@ -1620,7 +1619,7 @@ impl PlatformRepository {
Ok(v) => v,
Err(_) => {
extra_description = Some(format!(" (actual version: {})", pretty_version));
- let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("{^(\\d+\\.\\d+\\.\\d+(?:\\.\\d+)?)}"),
&pretty_version,
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 7687db0d..9a656a65 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, php_regex, urlencode,
@@ -584,7 +584,7 @@ impl ForgejoDriver {
let links = explode(",", &header);
for link in links {
- let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if Preg::match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), &link, Some(&mut m))
&& let Some(url) = m.get(&CaptureKey::ByIndex(1))
{
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index 9558e3b2..964c4b10 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
@@ -84,7 +84,7 @@ impl GitBitbucketDriver {
/// @inheritDoc
pub fn initialize(&mut self) -> anyhow::Result<()> {
- let mut m: indexmap::IndexMap<CaptureKey, String> = indexmap::IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if !Preg::is_match3(
php_regex!(r"#^https?://bitbucket\.org/([^/]+)/([^/]+?)(?:\.git|/?)?$#i"),
&self.inner.url,
diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs
index f39e142a..c46a6664 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath,
@@ -199,7 +199,7 @@ impl GitDriver {
if !branches.contains(&"* master".to_string()) {
for branch in &branches {
if !branch.is_empty() {
- let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut caps = PregMatchedGroups::new();
if Preg::match3(php_regex!(r"{^\* +(\S+)}"), branch, Some(&mut caps))
&& let Some(name) = caps.get(&CaptureKey::ByIndex(1))
{
@@ -311,7 +311,7 @@ impl GitDriver {
);
for tag in self.inner.process.borrow().split_lines(&output) {
if !tag.is_empty() {
- let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut caps = PregMatchedGroups::new();
if Preg::match3(
php_regex!(r"{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}"),
&tag,
@@ -350,7 +350,7 @@ impl GitDriver {
);
for branch in self.inner.process.borrow().split_lines(&output) {
if !branch.is_empty() && !Preg::is_match(php_regex!(r"{^ *[^/]+/HEAD }"), &branch) {
- let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut caps = PregMatchedGroups::new();
if Preg::match3(
php_regex!(r"{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}"),
&branch,
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 4c0df86a..10a61feb 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_map,
@@ -70,7 +70,7 @@ impl GitHubDriver {
}
pub fn initialize(&mut self) -> anyhow::Result<()> {
- let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut match_ = PregMatchedGroups::new();
if !Preg::is_match3(
php_regex!(
r"#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#"
@@ -495,7 +495,7 @@ impl GitHubDriver {
let mut key: Option<String> = None;
for line in preg_split(php_regex!(r"{\r?\n}"), &funding) {
let line = trim(&line, None);
- let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if Preg::is_match3(php_regex!(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();
@@ -503,7 +503,7 @@ impl GitHubDriver {
key = Some(g1);
continue;
}
- let mut m2: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m2 = PregMatchedGroups::new();
if Preg::is_match3(php_regex!(r"{^\[(.*?)\](?:\s*#.*)?$}"), &g2, Some(&mut m2)) {
let inner = m2.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
for item in array_map(
@@ -538,7 +538,7 @@ impl GitHubDriver {
} else if Preg::is_match3(php_regex!(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();
+ let mut tmp = PregMatchedGroups::new();
Preg::is_match3(php_regex!(r"{^-\s*(.+)(?:\s+#.*)?$}"), &line, Some(&mut m))
|| Preg::is_match3(php_regex!(r"{^(.+),(?:\s*#.*)?$}"), &line, Some(&mut tmp))
&& {
@@ -936,7 +936,7 @@ impl GitHubDriver {
url: &str,
_deep: bool,
) -> anyhow::Result<bool> {
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if !Preg::is_match3(
php_regex!(
r"#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#"
@@ -1284,7 +1284,7 @@ impl GitHubDriver {
let links = explode(",", &header);
for link in &links {
- let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if Preg::is_match3(php_regex!(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 df1ad686..c141cc9a 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
@@ -81,7 +81,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) -> anyhow::Result<()> {
- let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut match_ = PregMatchedGroups::new();
if !Preg::is_match3(Self::URL_REGEX, &self.inner.url, Some(&mut match_)) {
return Err(InvalidArgumentException::new(format!(
"The GitLab repository URL {} is invalid. It must be the HTTP URL of a GitLab project.",
@@ -945,7 +945,7 @@ impl GitLabDriver {
url: &str,
_deep: bool,
) -> anyhow::Result<bool> {
- let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut match_ = PregMatchedGroups::new();
if !Preg::is_match3(Self::URL_REGEX, url, Some(&mut match_)) {
return Ok(false);
}
@@ -1011,7 +1011,7 @@ impl GitLabDriver {
let links = explode(",", &header);
for link in &links {
- let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut match_ = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r#"{<(.+?)>; *rel="next"}"#),
link,
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index f4e02685..d617099e 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable, php_regex};
@@ -233,7 +233,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();
+ let mut m = PregMatchedGroups::new();
if Preg::match3(php_regex!(r"(^([^\s]+)\s+\d+:(.*)$)"), &tag, Some(&mut m)) {
tags.insert(
m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(),
@@ -263,7 +263,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();
+ let mut m = PregMatchedGroups::new();
if Preg::match3(
php_regex!(r"(^([^\s]+)\s+\d+:([a-f0-9]+))"),
&branch,
@@ -288,7 +288,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();
+ let mut m = PregMatchedGroups::new();
if Preg::match3(
php_regex!(r"(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)"),
&branch,
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index dd74400d..297e8f33 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::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
PhpMixed, RuntimeException, php_regex, stripos, strrpos, strtr, substr, trim,
@@ -318,7 +318,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();
+ let mut m = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r"{^Last Changed Date: ([^(]+)}"),
&line,
@@ -350,7 +350,7 @@ impl SvnDriver {
for line in self.inner.process.borrow().split_lines(&output) {
let line = trim(&line, None);
if !line.is_empty() {
- let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"),
&line,
@@ -401,7 +401,7 @@ impl SvnDriver {
for line in self.inner.process.borrow().split_lines(&output) {
let line = trim(&line, None);
if !line.is_empty() {
- let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"),
&line,
@@ -443,7 +443,7 @@ impl SvnDriver {
{
let line = trim(&line, None);
if !line.is_empty() {
- let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut m = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"),
&line,