aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-02 04:38:33 +0900
committernsfisis <nsfisis@gmail.com>2026-08-02 04:38:33 +0900
commita5c6eaee73e4008a51d71c925b4fd410b27578c8 (patch)
treea80becf52f7bd95654b6c2b262d3d26374d667ce /crates/shirabe/src/package
parent7be062404175fad6fc08b75c57c9e14be6ae4c24 (diff)
downloadphp-shirabe-a5c6eaee73e4008a51d71c925b4fd410b27578c8.tar.gz
php-shirabe-a5c6eaee73e4008a51d71c925b4fd410b27578c8.tar.zst
php-shirabe-a5c6eaee73e4008a51d71c925b4fd410b27578c8.zip
fix(symfony-finder): make Glob::to_regex regex-crate compatible
Glob::toRegex emits PCRE-only constructs — the (?=[^\.]) look-ahead for the strict-leading-dot rule, the possessive [^/]++ in /**/ segments, and, via BaseExcludeFilter, the (?=$|/) dir-boundary look-ahead — which the regex crate cannot compile, so `archive` and every ArchivableFilesFinder path panicked. Rewrite the port to tokenize the glob (mirroring the PHP loop's dispatch) and resolve every no-dot constraint by recursive union expansion. The dir boundary must take part in that expansion (a trailing `*` matching zero characters drops the constraint onto the boundary itself), so BaseExcludeFilter now uses the new Glob::to_regex_dir_boundary instead of string surgery. Equivalence was verified against PHP 8.5.8 (vendored Glob.php + preg_match) over 66,176 glob x flag x subject combinations with zero divergence. Un-ignores the five archiver tests blocked on this and updates GitExcludeFilterTest's expected pattern text, an explicitly authorized exception to the no-test-modification rule. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package')
-rw-r--r--crates/shirabe/src/package/archiver/base_exclude_filter.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/shirabe/src/package/archiver/base_exclude_filter.rs b/crates/shirabe/src/package/archiver/base_exclude_filter.rs
index fa2007fb..05bd7adc 100644
--- a/crates/shirabe/src/package/archiver/base_exclude_filter.rs
+++ b/crates/shirabe/src/package/archiver/base_exclude_filter.rs
@@ -59,14 +59,14 @@ impl BaseExcludeFilterBase {
let rule = rule.trim_matches('/');
- let glob_regex = Glob::to_regex(rule, true, true);
- let rule_regex = &glob_regex[2..glob_regex.len() - 2];
+ // Regex pattern compatibility:
+ // PHP strips the delimiters/anchors off Glob::toRegex output and appends the
+ // `(?=$|/)` look-ahead, which the regex crate cannot compile. The boundary has
+ // to participate in Glob's no-dot union expansion, so it is woven into the
+ // body by to_regex_dir_boundary instead of being appended here.
+ let rule_regex = Glob::to_regex_dir_boundary(rule, true, true);
- (
- format!("{{{}{}(?=$|/)}}", pattern, rule_regex),
- negate,
- false,
- )
+ (format!("{{{}{}}}", pattern, rule_regex), negate, false)
}
}