Skip to content

Commit 625747a

Browse files
committed
filter-repo.py sample callback
1 parent 37e5c34 commit 625747a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

other-test-repos/filter-repo.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
3+
# https://stackoverflow.com/questions/64160917/how-to-use-git-filter-repo-as-a-library-with-the-python-module-interface/64160918#64160918
4+
5+
import git_filter_repo
6+
7+
def blob_callback(blob, callback_metadata):
8+
blob.data = blob.data.replace(b'd1', b'asdf')
9+
10+
# Args deduced from:
11+
# print(git_filter_repo.FilteringOptions.parse_args(['--refs', 'HEAD', '--force'], error_on_empty=False))
12+
args = git_filter_repo.FilteringOptions.default_options()
13+
args.force = True
14+
args.partial = True
15+
args.refs = ['HEAD']
16+
args.repack=False
17+
args.replace_refs='update-no-add'
18+
19+
git_filter_repo.RepoFilter(
20+
args,
21+
blob_callback=blob_callback
22+
).run()

0 commit comments

Comments
 (0)