Commit c1d8461
committed
filter-repo: fix --replace-text for python3.14
Our handling of globs for --replace-text makes use of fnmatch.translate
from the python standard library. Unfortunately, fnmatch.translate
doesn't just give a regex that can match the given glob somewhere, it
gives a regex that will only match if the string it is comparing to is
exactly that glob. We need a substring search, though, so we have to
use an ugly hack to butcher the returned regex from fnmatch to get it
to be what we want. (It would be nice if python's fnmatch.translate()
took options for what was wanted, but it doesn't.) This is fine, except
that...
python3.14 added '\z' as a synonym for '\Z' in regexes. No special
reason, they just wanted there to be more than one way to do it.
Naturally, fnmatch.translate() uses '\z' instead of '\Z', so our regex
hackery in glob_to_regex() wasn't looking for the right stuff to hack
off, causing the globs to fail to match text as expected.
Add a python >= 3.14 hack to the existing python variation hacks in
glob_to_regex() so we can handle this case too.
While at it, the --replace-text test in t9394 did replacements on a
literal, a glob, and a regex, but it only verified that the glob and
regex replacements worked. Supplement it with a check that the
literal replacement worked too.
Signed-off-by: Elijah Newren <[email protected]>1 parent e81bcf3 commit c1d8461
File tree
2 files changed
+6
-0
lines changed- t
2 files changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
654 | 654 | | |
655 | 655 | | |
656 | 656 | | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
657 | 660 | | |
658 | 661 | | |
659 | 662 | | |
| |||
0 commit comments