aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs5
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs10
-rw-r--r--crates/shirabe/src/repository/vcs/git_driver.rs55
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs50
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs19
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs65
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs139
7 files changed, 144 insertions, 199 deletions
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 9a656a65..9e156418 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, PregMatchedGroups};
+use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, php_regex, urlencode,
@@ -584,8 +584,7 @@ impl ForgejoDriver {
let links = explode(",", &header);
for link in links {
- let mut m = PregMatchedGroups::new();
- if Preg::match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), &link, Some(&mut m))
+ if let Some(m) = Preg::match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), &link)
&& let Some(url) = m.get(&CaptureKey::ByIndex(1))
{
return Some(url.clone());
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index 964c4b10..cf1f5f98 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, PregMatchedGroups};
+use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
@@ -84,18 +84,16 @@ impl GitBitbucketDriver {
/// @inheritDoc
pub fn initialize(&mut self) -> anyhow::Result<()> {
- let mut m = PregMatchedGroups::new();
- if !Preg::is_match3(
+ let Some(m) = Preg::is_match3(
php_regex!(r"#^https?://bitbucket\.org/([^/]+)/([^/]+?)(?:\.git|/?)?$#i"),
&self.inner.url,
- Some(&mut m),
- ) {
+ ) else {
return Err(InvalidArgumentException::new(format!(
"The Bitbucket repository URL {} is invalid. It must be the HTTPS URL of a Bitbucket repository.",
self.inner.url.clone(),
))
.into());
- }
+ };
self.owner = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
self.repository = m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs
index c46a6664..99275e98 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, PregMatchedGroups};
+use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath,
@@ -198,14 +198,12 @@ impl GitDriver {
let branches = self.inner.process.borrow().split_lines(&output);
if !branches.contains(&"* master".to_string()) {
for branch in &branches {
- if !branch.is_empty() {
- let mut caps = PregMatchedGroups::new();
- if Preg::match3(php_regex!(r"{^\* +(\S+)}"), branch, Some(&mut caps))
- && let Some(name) = caps.get(&CaptureKey::ByIndex(1))
- {
- self.root_identifier = Some(name.clone());
- break;
- }
+ if !branch.is_empty()
+ && let Some(caps) = Preg::match3(php_regex!(r"{^\* +(\S+)}"), branch)
+ && let Some(name) = caps.get(&CaptureKey::ByIndex(1))
+ {
+ self.root_identifier = Some(name.clone());
+ break;
}
}
}
@@ -310,21 +308,20 @@ impl GitDriver {
Some(&self.repo_dir),
);
for tag in self.inner.process.borrow().split_lines(&output) {
- if !tag.is_empty() {
- let mut caps = PregMatchedGroups::new();
- if Preg::match3(
+ if !tag.is_empty()
+ && let Some(caps) = Preg::match3(
php_regex!(r"{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}"),
&tag,
- Some(&mut caps),
- ) && let (Some(hash), Some(name)) = (
+ )
+ && let (Some(hash), Some(name)) = (
caps.get(&CaptureKey::ByIndex(1)),
caps.get(&CaptureKey::ByIndex(2)),
- ) {
- self.tags
- .as_mut()
- .unwrap()
- .insert(name.clone(), hash.clone());
- }
+ )
+ {
+ self.tags
+ .as_mut()
+ .unwrap()
+ .insert(name.clone(), hash.clone());
}
}
}
@@ -349,19 +346,19 @@ impl GitDriver {
Some(&self.repo_dir),
);
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 = PregMatchedGroups::new();
- if Preg::match3(
+ if !branch.is_empty()
+ && !Preg::is_match(php_regex!(r"{^ *[^/]+/HEAD }"), &branch)
+ && let Some(caps) = Preg::match3(
php_regex!(r"{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}"),
&branch,
- Some(&mut caps),
- ) && let (Some(name), Some(hash)) = (
+ )
+ && let (Some(name), Some(hash)) = (
caps.get(&CaptureKey::ByIndex(1)),
caps.get(&CaptureKey::ByIndex(2)),
- ) && !name.starts_with('-')
- {
- branches.insert(name.clone(), hash.clone());
- }
+ )
+ && !name.starts_with('-')
+ {
+ branches.insert(name.clone(), hash.clone());
}
}
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 10a61feb..7cbceaf2 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, PregMatchedGroups};
+use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_map,
@@ -70,20 +70,18 @@ impl GitHubDriver {
}
pub fn initialize(&mut self) -> anyhow::Result<()> {
- let mut match_ = PregMatchedGroups::new();
- if !Preg::is_match3(
+ let Some(match_) = Preg::is_match3(
php_regex!(
r"#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#"
),
&self.inner.url,
- Some(&mut match_),
- ) {
+ ) else {
return Err(InvalidArgumentException::new(format!(
"The GitHub repository URL {} is invalid.",
self.inner.url.clone(),
))
.into());
- }
+ };
self.owner = match_
.get(&CaptureKey::ByIndex(3))
@@ -495,16 +493,14 @@ 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 = PregMatchedGroups::new();
- if Preg::is_match3(php_regex!(r"{^(\w+)\s*:\s*(.+)$}"), &line, Some(&mut m)) {
+ if let Some(m) = Preg::is_match3(php_regex!(r"{^(\w+)\s*:\s*(.+)$}"), &line) {
let g1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
let g2 = m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
if g2 == "[" {
key = Some(g1);
continue;
}
- let mut m2 = PregMatchedGroups::new();
- if Preg::is_match3(php_regex!(r"{^\[(.*?)\](?:\s*#.*)?$}"), &g2, Some(&mut m2)) {
+ if let Some(m2) = Preg::is_match3(php_regex!(r"{^\[(.*?)\](?:\s*#.*)?$}"), &g2) {
let inner = m2.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
for item in array_map(
|s: &String| trim(s, None),
@@ -518,11 +514,9 @@ impl GitHubDriver {
);
result.push(entry);
}
- } else if Preg::is_match3(
- php_regex!(r"{^([^#].*?)(?:\s+#.*)?$}"),
- &g2,
- Some(&mut m2),
- ) {
+ } else if let Some(m2) =
+ Preg::is_match3(php_regex!(r"{^([^#].*?)(?:\s+#.*)?$}"), &g2)
+ {
let mut entry = IndexMap::new();
entry.insert("type".to_string(), PhpMixed::String(g1.clone()));
entry.insert(
@@ -535,17 +529,12 @@ impl GitHubDriver {
result.push(entry);
}
key = None;
- } else if Preg::is_match3(php_regex!(r"{^(\w+)\s*:\s*#\s*$}"), &line, Some(&mut m)) {
+ } else if let Some(m) = Preg::is_match3(php_regex!(r"{^(\w+)\s*:\s*#\s*$}"), &line) {
key = Some(m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default());
- } else if key.is_some() && {
- 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))
- && {
- m = tmp;
- true
- }
- } {
+ } 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))
+ {
let mut entry = IndexMap::new();
entry.insert(
"type".to_string(),
@@ -936,16 +925,14 @@ impl GitHubDriver {
url: &str,
_deep: bool,
) -> anyhow::Result<bool> {
- let mut matches = PregMatchedGroups::new();
- if !Preg::is_match3(
+ let Some(matches) = Preg::is_match3(
php_regex!(
r"#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#"
),
url,
- Some(&mut matches),
- ) {
+ ) else {
return Ok(false);
- }
+ };
let origin_url = matches
.get(&CaptureKey::ByIndex(2))
@@ -1284,8 +1271,7 @@ impl GitHubDriver {
let links = explode(",", &header);
for link in &links {
- let mut m = PregMatchedGroups::new();
- if Preg::is_match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), link, Some(&mut m)) {
+ if let Some(m) = Preg::is_match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), link) {
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 c141cc9a..1887ddc4 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, PregMatchedGroups};
+use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
@@ -81,14 +81,13 @@ 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_ = PregMatchedGroups::new();
- if !Preg::is_match3(Self::URL_REGEX, &self.inner.url, Some(&mut match_)) {
+ let Some(match_) = Preg::is_match3(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(),
))
.into());
- }
+ };
let guessed_domain = match_
.get(&CaptureKey::ByName("domain".to_string()))
@@ -945,10 +944,9 @@ impl GitLabDriver {
url: &str,
_deep: bool,
) -> anyhow::Result<bool> {
- let mut match_ = PregMatchedGroups::new();
- if !Preg::is_match3(Self::URL_REGEX, url, Some(&mut match_)) {
+ let Some(match_) = Preg::is_match3(Self::URL_REGEX, url) else {
return Ok(false);
- }
+ };
let scheme = match_
.get(&CaptureKey::ByName("scheme".to_string()))
@@ -1011,12 +1009,7 @@ impl GitLabDriver {
let links = explode(",", &header);
for link in &links {
- let mut match_ = PregMatchedGroups::new();
- if Preg::is_match3(
- php_regex!(r#"{<(.+?)>; *rel="next"}"#),
- link,
- Some(&mut match_),
- ) {
+ if let Some(match_) = Preg::is_match3(php_regex!(r#"{<(.+?)>; *rel="next"}"#), link) {
return Some(
match_
.get(&CaptureKey::ByIndex(1))
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index d617099e..0933a643 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, PregMatchedGroups};
+use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable, php_regex};
@@ -232,14 +232,13 @@ impl HgDriver {
Some(&self.repo_dir),
);
for tag in self.inner.process.borrow().split_lines(&output) {
- if !tag.is_empty() {
- 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(),
- m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
- );
- }
+ if !tag.is_empty()
+ && let Some(m) = Preg::match3(php_regex!(r"(^([^\s]+)\s+\d+:(.*)$)"), &tag)
+ {
+ tags.insert(
+ m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(),
+ m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
+ );
}
}
tags.shift_remove("tip");
@@ -262,20 +261,16 @@ impl HgDriver {
Some(&self.repo_dir),
);
for branch in self.inner.process.borrow().split_lines(&output) {
- if !branch.is_empty() {
- let mut m = PregMatchedGroups::new();
- 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(
- name,
- m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
- );
- }
+ if !branch.is_empty()
+ && let Some(m) =
+ Preg::match3(php_regex!(r"(^([^\s]+)\s+\d+:([a-f0-9]+))"), &branch)
+ {
+ let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
+ if !name.starts_with('-') {
+ branches.insert(
+ name,
+ m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
+ );
}
}
}
@@ -287,20 +282,16 @@ impl HgDriver {
Some(&self.repo_dir),
);
for branch in self.inner.process.borrow().split_lines(&output) {
- if !branch.is_empty() {
- let mut m = PregMatchedGroups::new();
- 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(
- name,
- m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
- );
- }
+ if !branch.is_empty()
+ && let Some(m) =
+ Preg::match3(php_regex!(r"(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)"), &branch)
+ {
+ let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
+ if !name.starts_with('-') {
+ bookmarks.insert(
+ name,
+ m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
+ );
}
}
}
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index db8c43f0..05380a17 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, PregMatchedGroups};
+use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
PhpMixed, RuntimeException, php_regex, stripos, strrpos, strtr, substr, trim,
@@ -317,18 +317,14 @@ impl SvnDriver {
&format!("{}{}{}", self.base_url, path, rev),
)?;
for line in self.inner.process.borrow().split_lines(&output) {
- if !line.is_empty() {
- let mut m = PregMatchedGroups::new();
- if Preg::is_match3(
- php_regex!(r"{^Last Changed Date: ([^(]+)}"),
- &line,
- Some(&mut m),
- ) {
- let date_str = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
- return Ok(shirabe_php_shim::date_create::<Utc>(date_str.trim())
- .ok()
- .map(|d| d.fixed_offset()));
- }
+ if !line.is_empty()
+ && let Some(m) =
+ Preg::is_match3(php_regex!(r"{^Last Changed Date: ([^(]+)}"), &line)
+ {
+ let date_str = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
+ return Ok(shirabe_php_shim::date_create::<Utc>(date_str.trim())
+ .ok()
+ .map(|d| d.fixed_offset()));
}
}
@@ -349,28 +345,23 @@ impl SvnDriver {
let mut last_rev: i64 = 0;
for line in self.inner.process.borrow().split_lines(&output) {
let line = trim(&line, None);
- if !line.is_empty() {
- let mut m = PregMatchedGroups::new();
- if Preg::is_match3(
- php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"),
- &line,
- Some(&mut m),
- ) {
- let rev: i64 = m
- .get(&CaptureKey::ByIndex(1))
- .and_then(|s| s.parse().ok())
- .unwrap_or(0);
- let path =
- m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
- if path == "./" {
- last_rev = rev;
- } else {
- let identifier = self.build_identifier(
- &format!("/{}/{}", self.tags_path, path),
- std::cmp::max(last_rev, rev),
- );
- tags.insert(path.trim_end_matches('/').to_string(), identifier);
- }
+ if !line.is_empty()
+ && 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)).cloned().unwrap_or_default();
+ if path == "./" {
+ last_rev = rev;
+ } else {
+ let identifier = self.build_identifier(
+ &format!("/{}/{}", self.tags_path, path),
+ std::cmp::max(last_rev, rev),
+ );
+ tags.insert(path.trim_end_matches('/').to_string(), identifier);
}
}
}
@@ -400,27 +391,23 @@ impl SvnDriver {
if !output.is_empty() {
for line in self.inner.process.borrow().split_lines(&output) {
let line = trim(&line, None);
- if !line.is_empty() {
- let mut m = PregMatchedGroups::new();
- if Preg::is_match3(
- php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"),
- &line,
- Some(&mut m),
- ) {
- let rev: i64 = m
- .get(&CaptureKey::ByIndex(1))
- .and_then(|s| s.parse().ok())
- .unwrap_or(0);
- let path = m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
- if path == "./" {
- let identifier = self.build_identifier(
- &format!("/{}", self.trunk_path.clone().unwrap_or_default()),
- rev,
- );
- branches.insert("trunk".to_string(), identifier.clone());
- self.root_identifier = Some(identifier);
- break;
- }
+ if !line.is_empty()
+ && 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)).cloned().unwrap_or_default();
+ if path == "./" {
+ let identifier = self.build_identifier(
+ &format!("/{}", self.trunk_path.clone().unwrap_or_default()),
+ rev,
+ );
+ branches.insert("trunk".to_string(), identifier.clone());
+ self.root_identifier = Some(identifier);
+ break;
}
}
}
@@ -442,29 +429,23 @@ impl SvnDriver {
.split_lines(&trim(&output, None))
{
let line = trim(&line, None);
- if !line.is_empty() {
- let mut m = PregMatchedGroups::new();
- if Preg::is_match3(
- php_regex!(r"{^\s*(\S+).*?(\S+)\s*$}"),
- &line,
- Some(&mut m),
- ) {
- let rev: i64 = m
- .get(&CaptureKey::ByIndex(1))
- .and_then(|s| s.parse().ok())
- .unwrap_or(0);
- let path =
- m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
- if path == "./" {
- last_rev = rev;
- } else {
- let identifier = self.build_identifier(
- &format!("/{}/{}", self.branches_path, path),
- std::cmp::max(last_rev, rev),
- );
- branches
- .insert(path.trim_end_matches('/').to_string(), identifier);
- }
+ if !line.is_empty()
+ && 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)).cloned().unwrap_or_default();
+ if path == "./" {
+ last_rev = rev;
+ } else {
+ let identifier = self.build_identifier(
+ &format!("/{}/{}", self.branches_path, path),
+ std::cmp::max(last_rev, rev),
+ );
+ branches.insert(path.trim_end_matches('/').to_string(), identifier);
}
}
}