mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-09-14 00:00:09 +02:00
cbacb6cd82
Python wants filenames with underscores instead of hyphens and with a .py extension. We really want the main file named git-filter-repo, but we can add a git_filter_repo.py symlink. Doing so dramatically simplifies the steps needed to import it as a library in external python scripts. Signed-off-by: Elijah Newren <newren@gmail.com>
17 lines
543 B
Python
Executable File
17 lines
543 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import re
|
|
import git_filter_repo as fr
|
|
|
|
def strip_cvs_keywords(blob):
|
|
# FIXME: Should first check if blob is a text file to avoid ruining
|
|
# binaries. Could use python.magic here, or just output blob.data to
|
|
# the unix 'file' command
|
|
pattern = r'\$(Id|Date|Source|Header|CVSHeader|Author|Revision):.*\$'
|
|
replacement = r'$\1$'
|
|
blob.data = re.sub(pattern, replacement, blob.data)
|
|
|
|
args = fr.FilteringOptions.parse_args(['--force'])
|
|
filter = fr.RepoFilter(args, blob_callback = strip_cvs_keywords)
|
|
filter.run()
|