mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-06 18:32:14 +02:00
filter-repo: add some preventative sanity checks
Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
9b88f3f094
commit
77d5e93135
@ -2112,6 +2112,7 @@ def tweak_commit(args, commit):
|
||||
wanted = False
|
||||
for (mod_type, match_type, path_expression) in path_changes:
|
||||
if mod_type == 'filter' and not wanted:
|
||||
assert match_type in ('match', 'glob', 'regex')
|
||||
if match_type == 'match' and filename_matches(path_expression, pathname):
|
||||
wanted = True
|
||||
if match_type == 'glob' and fnmatch.fnmatch(pathname, path_expression):
|
||||
@ -2120,6 +2121,7 @@ def tweak_commit(args, commit):
|
||||
wanted = True
|
||||
elif mod_type == 'rename':
|
||||
old_exp, new_exp = path_expression.split(':')
|
||||
assert match_type in ('prefix',)
|
||||
if match_type == 'prefix' and pathname.startswith(old_exp):
|
||||
pathname = pathname.replace(old_exp, new_exp, 1)
|
||||
return pathname if (wanted == filtering_is_inclusive) else None
|
||||
|
Loading…
Reference in New Issue
Block a user