mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-06 02:12:17 +02:00
filter-repo: make default replacement text a variable
Allow external scripts that import git-filter-repo to change the value of the default replacement text instead of having it hardcoded within some function. Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
31f00a9ff8
commit
caa05d15b4
@ -1619,6 +1619,7 @@ class GitUtils(object):
|
|||||||
print(decode(version[0:12]))
|
print(decode(version[0:12]))
|
||||||
|
|
||||||
class FilteringOptions(object):
|
class FilteringOptions(object):
|
||||||
|
default_replace_text = b'***REMOVED***'
|
||||||
class AppendFilter(argparse.Action):
|
class AppendFilter(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
user_path = values
|
user_path = values
|
||||||
@ -1818,8 +1819,8 @@ EXAMPLES
|
|||||||
"By default, each expression is treated as literal text, "
|
"By default, each expression is treated as literal text, "
|
||||||
"but 'regex:' and 'glob:' prefixes are supported. You can "
|
"but 'regex:' and 'glob:' prefixes are supported. You can "
|
||||||
"end the line with '==>' and some replacement text to "
|
"end the line with '==>' and some replacement text to "
|
||||||
"choose a replacement choice other than the default of "
|
"choose a replacement choice other than the default of '{}'."
|
||||||
"'***REMOVED***'. "))
|
.format(decode(FilteringOptions.default_replace_text))))
|
||||||
contents.add_argument('--strip-blobs-bigger-than', metavar='SIZE',
|
contents.add_argument('--strip-blobs-bigger-than', metavar='SIZE',
|
||||||
dest='max_blob_size', default=0,
|
dest='max_blob_size', default=0,
|
||||||
help=_("Strip blobs (files) bigger than specified size (e.g. '5M', "
|
help=_("Strip blobs (files) bigger than specified size (e.g. '5M', "
|
||||||
@ -2089,7 +2090,7 @@ EXAMPLES
|
|||||||
line = line.rstrip(b'\r\n')
|
line = line.rstrip(b'\r\n')
|
||||||
|
|
||||||
# Determine the replacement
|
# Determine the replacement
|
||||||
replacement = b'***REMOVED***'
|
replacement = FilteringOptions.default_replace_text
|
||||||
if b'==>' in line:
|
if b'==>' in line:
|
||||||
line, replacement = line.rsplit(b'==>', 1)
|
line, replacement = line.rsplit(b'==>', 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user