diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
| commit | e093b2be1c333e67c96aebb0a5291bea9ae3d6db (patch) | |
| tree | 0743fad689f419959c3a898605e21485087884fa /crates/shirabe/src/repository/vcs/gitlab_driver.rs | |
| parent | 050c56ef263d90d862ef565bc1762909110e02eb (diff) | |
| download | php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.gz php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.zst php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.zip | |
refactor(preg): drop the offset argument from preg_match
Every call site but one passed offset 0. The remaining one, the UTF-8
chunking loop in Application, slices the subject instead: its pattern has
no anchor or lookaround, so matching a suffix is equivalent to starting
the search at that offset.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/vcs/gitlab_driver.rs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/gitlab_driver.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index 6054d941..229d043b 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -19,7 +19,7 @@ use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed, array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array_loose, is_array, - is_string, ord, php_regex, preg_match2, preg_replace, strpos, strtolower, + is_string, ord, php_regex, preg_match, preg_replace, strpos, strtolower, }; /// Driver for GitLab API, use the Git driver for local checkouts. @@ -80,7 +80,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 Some(match_) = preg_match2(Self::URL_REGEX, &self.inner.url, 0) else { + let Some(match_) = preg_match(Self::URL_REGEX, &self.inner.url) else { return Err(InvalidArgumentException::new(format!( "The GitLab repository URL {} is invalid. It must be the HTTP URL of a GitLab project.", self.inner.url.clone(), @@ -382,7 +382,7 @@ impl GitLabDriver { // Convert the root identifier to a cacheable commit id let mut identifier = identifier.to_string(); - if preg_match2(php_regex!(r"{[a-f0-9]{40}}i"), &identifier, 0).is_none() { + if preg_match(php_regex!(r"{[a-f0-9]{40}}i"), &identifier).is_none() { let branches = self.get_branches()?; if let Some(sha) = branches.get(&identifier) { identifier = sha.clone(); @@ -926,7 +926,7 @@ impl GitLabDriver { url: &str, _deep: bool, ) -> anyhow::Result<bool> { - let Some(match_) = preg_match2(Self::URL_REGEX, url, 0) else { + let Some(match_) = preg_match(Self::URL_REGEX, url) else { return Ok(false); }; @@ -977,7 +977,7 @@ impl GitLabDriver { let links = explode(",", &header); for link in &links { - if let Some(match_) = preg_match2(php_regex!(r#"{<(.+?)>; *rel="next"}"#), link, 0) { + if let Some(match_) = preg_match(php_regex!(r#"{<(.+?)>; *rel="next"}"#), link) { return Some(match_.get(1).unwrap_or_default().to_string()); } } |
