mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-06 18:32:14 +02:00
filter-repo: allow RepoFilter.run to be passed callbacks
Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
55c2c32d7c
commit
d0037275af
@ -2521,7 +2521,12 @@ class RepoFilter(object):
|
|||||||
reset_or_tag.ref = RepoFilter.new_tagname(args, reset_or_tag.ref, shortname)
|
reset_or_tag.ref = RepoFilter.new_tagname(args, reset_or_tag.ref, shortname)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(args):
|
def run(args,
|
||||||
|
blob_callback = None,
|
||||||
|
commit_callback = None,
|
||||||
|
tag_callback = None,
|
||||||
|
reset_callback = None,
|
||||||
|
everything_callback = None):
|
||||||
if args.debug:
|
if args.debug:
|
||||||
print("[DEBUG] Passed arguments:\n{}".format(args))
|
print("[DEBUG] Passed arguments:\n{}".format(args))
|
||||||
|
|
||||||
@ -2579,12 +2584,23 @@ class RepoFilter(object):
|
|||||||
print("[DEBUG] Running: {}".format(' '.join(fip_cmd)))
|
print("[DEBUG] Running: {}".format(' '.join(fip_cmd)))
|
||||||
print(" (using the following file as input: {})".format(fe_filt))
|
print(" (using the following file as input: {})".format(fe_filt))
|
||||||
|
|
||||||
|
# Set up the callbacks
|
||||||
|
def actual_commit_callback(c):
|
||||||
|
RepoFilter.tweak_commit(args, c)
|
||||||
|
commit_callback and commit_callback(c)
|
||||||
|
def actual_tag_callback(t):
|
||||||
|
RepoFilter.handle_tag(args, t, shortname = True)
|
||||||
|
tag_callback and tag_callback(t)
|
||||||
|
def actual_reset_callback(r):
|
||||||
|
RepoFilter.handle_tag(args, r)
|
||||||
|
reset_callback and reset_callback(r)
|
||||||
|
|
||||||
# Create and run the filter
|
# Create and run the filter
|
||||||
filter = FastExportFilter(
|
filter = FastExportFilter(blob_callback = blob_callback,
|
||||||
commit_callback = lambda c : RepoFilter.tweak_commit(args, c),
|
commit_callback = actual_commit_callback,
|
||||||
tag_callback = lambda t : RepoFilter.handle_tag(args, t, shortname = True),
|
tag_callback = actual_tag_callback,
|
||||||
reset_callback = lambda r : RepoFilter.handle_tag(args, r),
|
reset_callback = actual_reset_callback,
|
||||||
)
|
everything_callback = everything_callback)
|
||||||
filter.run(input, output, fast_import_pipes = pipes, quiet = args.quiet)
|
filter.run(input, output, fast_import_pipes = pipes, quiet = args.quiet)
|
||||||
|
|
||||||
# Close the output, ensure fast-export and fast-import have completed
|
# Close the output, ensure fast-export and fast-import have completed
|
||||||
|
Loading…
Reference in New Issue
Block a user