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.
|
|
|
|
|
|
|
|
Also, note that splicing repos may need some special care as fast-export
|
|
|
|
only shows the files that changed relative to the first parent, so there
|
|
|
|
may be gotchas if you are to splice near merge commits; this example does
|
|
|
|
not try to handle any such special cases.
|
|
|
|
"""
|
|
|
|
|
2018-11-05 15:31:06 +01:00
|
|
|
import re
|
2019-02-10 03:24:37 +01:00
|
|
|
import git_filter_repo as fr
|
2018-11-05 15:31:06 +01:00
|
|
|
|
|
|
|
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
|
2019-04-28 00:18:59 +02:00
|
|
|
pattern = br'\$(Id|Date|Source|Header|CVSHeader|Author|Revision):.*\$'
|
|
|
|
replacement = br'$\1$'
|
2018-11-05 15:31:06 +01:00
|
|
|
blob.data = re.sub(pattern, replacement, blob.data)
|
|
|
|
|
2019-02-10 03:24:37 +01:00
|
|
|
args = fr.FilteringOptions.parse_args(['--force'])
|
|
|
|
filter = fr.RepoFilter(args, blob_callback = strip_cvs_keywords)
|
2018-11-05 15:31:06 +01:00
|
|
|
filter.run()
|