1

Trying to run git-filter-repo command from python. I can't figure out how this should be done. git filter-repo --path README.md --path guides/ --path tools/releases

So far I have:

    filtering_options = git_filter_repo.FilteringOptions.default_options()
    filtering_options.source = _fragment_repo_git_directory(workspace, "svn-import")
    filtering_options.target = _main_repo_git_directory(workspace).encode()
    filtering_options.force = True

    filtering_options.replace_refs = "update no add"
    repo_filter = git_filter_repo.RepoFilter(
        filtering_options,
        #  ?????????
    )
    repo_filter.run()
Mikhail
  • 1,092
  • 1
  • 11
  • 30

1 Answers1

0

You can take inspiration from the newren/git-filter-repo/contrib/filter-repo-demos/lint-history script, which does use a callback function as your # ????????? argument:

try:
  import git_filter_repo as fr
except ImportError:
  raise SystemExit("Error: Couldn't find git_filter_repo.py.  Did you forget to make a symlink to git-filter-repo named git_filter_repo.py or did you forget to put the latter in your PYTHONPATH?")

def lint_non_binary_blobs(blob, metadata):
  ...

filter = fr.RepoFilter(args, blob_callback=lint_non_binary_blobs)
filter.run()
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283