2019-04-01 23:35:49 +02:00
|
|
|
#!/usr/bin/env python3
|
2018-11-05 15:31:06 +01:00
|
|
|
|
2019-03-05 20:00:11 +01:00
|
|
|
"""
|
|
|
|
Please see the
|
|
|
|
***** API BACKWARD COMPATIBILITY CAVEAT *****
|
|
|
|
near the top of git-filter-repo
|
|
|
|
"""
|
|
|
|
|
2018-11-05 15:31:06 +01:00
|
|
|
import sys
|
2019-02-10 03:24:37 +01:00
|
|
|
import git_filter_repo as fr
|
2018-11-05 15:31:06 +01:00
|
|
|
|
|
|
|
if len(sys.argv) != 3:
|
|
|
|
raise SystemExit("Syntax:\n %s SOURCE_REPO TARGET_REPO")
|
|
|
|
source_repo = sys.argv[1]
|
|
|
|
target_repo = sys.argv[2]
|
|
|
|
|
2019-02-10 03:24:37 +01:00
|
|
|
total_objects = fr.GitUtils.get_total_objects(source_repo) # blobs+trees
|
|
|
|
total_commits = fr.GitUtils.get_commit_count(source_repo)
|
2018-11-05 15:31:06 +01:00
|
|
|
object_count = 0
|
|
|
|
commit_count = 0
|
|
|
|
|
|
|
|
def print_progress():
|
|
|
|
global object_count, commit_count, total_objects, total_commits
|
2019-04-01 23:35:49 +02:00
|
|
|
print("\rRewriting commits... %d/%d (%d objects)"
|
|
|
|
% (commit_count, total_commits, object_count), end='')
|
2018-11-05 15:31:06 +01:00
|
|
|
|
|
|
|
def my_blob_callback(blob):
|
|
|
|
global object_count
|
|
|
|
object_count += 1
|
|
|
|
print_progress()
|
|
|
|
|
|
|
|
def my_commit_callback(commit):
|
|
|
|
global commit_count
|
|
|
|
commit_count += 1
|
|
|
|
print_progress()
|
|
|
|
|
2019-02-10 03:24:37 +01:00
|
|
|
args = fr.FilteringOptions.parse_args(['--force', '--quiet'])
|
|
|
|
filter = fr.RepoFilter(args,
|
|
|
|
blob_callback = my_blob_callback,
|
|
|
|
commit_callback = my_commit_callback)
|
2018-11-05 15:31:06 +01:00
|
|
|
filter.run()
|