How to use --msg-filter
Closed this issue · 1 comments
achimmihca commented
The help text says:
--msg-filter External program / script to modify svn log message
What parameters are given to the external program?
I want to extend the commit message with a link to our old repo using the revision number.
achimmihca commented
I took a look at https://github.com/svn-all-fast-export/svn2git/blob/master/src/repository.cpp.
The msg-filter program receives the old commit message on stdin.
It must output the new commit message on stdout.
Thus, the following Python script can be used to parse the revision number from the old commit message and modify the commit message as desired:
#!/usr/bin/python3
import fileinput
import re
# The original commit message is given on stdin.
commitMessage = ""
lastLine = ""
for line in fileinput.input():
commitMessage += line
if line.strip():
lastLine = line
# Get revision number from last line.
# The revision number is added to the commit message by --add-metadata option of svn-all-fast-export.
revisionNumber = ""
if lastLine:
match = re.search(r"revision=(\d+)", lastLine)
if match:
revisionNumber = match.group(1)
if revisionNumber:
pass # Modify the commit message here.
# The new commit message is returned on stdout
print(commitMessage, end="")