mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-28 17:41:14 +00:00
git: use RegexSet in place of concatenating multiple glob patterns
Perhaps, this would handle patterns like ["a(b", "c)"] better. It might not be correct to error out on "(", but should be better than building wrong regexp pattern "a(b|c)".
This commit is contained in:
parent
a07574a233
commit
915f76f4d9
1 changed files with 7 additions and 6 deletions
|
@ -519,12 +519,13 @@ pub fn fetch(
|
||||||
remote.disconnect()?;
|
remote.disconnect()?;
|
||||||
tracing::debug!("import_refs");
|
tracing::debug!("import_refs");
|
||||||
if let Some(globs) = branch_name_globs {
|
if let Some(globs) = branch_name_globs {
|
||||||
let pattern = format!(
|
let branch_regex = regex::RegexSet::new(
|
||||||
"^({})$",
|
globs
|
||||||
globs.iter().map(|glob| glob.replace('*', ".*")).join("|")
|
.iter()
|
||||||
);
|
.map(|glob| format!("^{}$", glob.replace('*', ".*"))),
|
||||||
tracing::debug!(?globs, ?pattern, "globs as regex");
|
)
|
||||||
let branch_regex = regex::Regex::new(&pattern).map_err(|_| GitFetchError::InvalidGlob)?;
|
.map_err(|_| GitFetchError::InvalidGlob)?;
|
||||||
|
tracing::debug!(?globs, ?branch_regex, "globs as regex");
|
||||||
import_some_refs(
|
import_some_refs(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
git_repo,
|
git_repo,
|
||||||
|
|
Loading…
Reference in a new issue