diff options
Diffstat (limited to 'crates/shirabe/src/repository/vcs/hg_driver.rs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/hg_driver.rs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs index f987eb4b..a346094c 100644 --- a/crates/shirabe/src/repository/vcs/hg_driver.rs +++ b/crates/shirabe/src/repository/vcs/hg_driver.rs @@ -12,7 +12,7 @@ use crate::util::Url; use chrono::{DateTime, FixedOffset, Utc}; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable}; +use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable, php_regex}; #[derive(Debug)] pub struct HgDriver { @@ -59,8 +59,11 @@ impl HgDriver { }.into()); } - let sanitized = - Preg::replace(r"{[^a-z0-9]}i", "-", &Url::sanitize(self.inner.url.clone())); + let sanitized = Preg::replace( + php_regex!(r"{[^a-z0-9]}i"), + "-", + &Url::sanitize(self.inner.url.clone()), + ); self.repo_dir = format!("{}/{}/", cache_vcs_dir, sanitized); let mut fs = Filesystem::new(None); @@ -242,7 +245,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(); - if Preg::match3(r"(^([^\s]+)\s+\d+:(.*)$)", &tag, Some(&mut m)) { + if Preg::match3(php_regex!(r"(^([^\s]+)\s+\d+:(.*)$)"), &tag, Some(&mut m)) { tags.insert( m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(), m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(), @@ -272,7 +275,11 @@ impl HgDriver { for branch in self.inner.process.borrow().split_lines(&output) { if !branch.is_empty() { let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::match3(r"(^([^\s]+)\s+\d+:([a-f0-9]+))", &branch, Some(&mut m)) { + if Preg::match3( + php_regex!(r"(^([^\s]+)\s+\d+:([a-f0-9]+))"), + &branch, + Some(&mut m), + ) { let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(); if !name.starts_with('-') { branches.insert( @@ -293,7 +300,11 @@ impl HgDriver { for branch in self.inner.process.borrow().split_lines(&output) { if !branch.is_empty() { let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::match3(r"(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)", &branch, Some(&mut m)) { + if Preg::match3( + php_regex!(r"(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)"), + &branch, + Some(&mut m), + ) { let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(); if !name.starts_with('-') { bookmarks.insert( @@ -320,7 +331,9 @@ impl HgDriver { deep: bool, ) -> anyhow::Result<bool> { if Preg::is_match( - r"#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i", + php_regex!( + r"#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i" + ), url, ) { return Ok(true); |
