mirror of
https://github.com/frej/fast-export.git
synced 2025-11-08 20:25:39 +01:00
- Allow skipping writing the branch name if the branch is 'master'. - Allow writing the branch name on the same line as the first line of the commit message separated by a colon, instead of it having its own line.
24 lines
957 B
Python
24 lines
957 B
Python
def build_filter(args):
|
|
return Filter(args)
|
|
|
|
class Filter:
|
|
def __init__(self, args):
|
|
args = {arg: True for arg in args.split(',')}
|
|
self.start = args.pop('start', False)
|
|
self.end = args.pop('end', False)
|
|
self.sameline = args.pop('sameline', False)
|
|
self.skip_master = args.pop('skipmaster', False)
|
|
|
|
if self.sameline and not self.start:
|
|
raise ValueError("sameline option only allowed if 'start' given")
|
|
if args:
|
|
raise ValueError("Unknown args: " + ','.join(args))
|
|
|
|
def commit_message_filter(self, commit_data):
|
|
if not (self.skip_master and commit_data['branch'] == 'master'):
|
|
if self.start:
|
|
sep = ': ' if self.sameline else '\n'
|
|
commit_data['desc'] = commit_data['branch'] + sep + commit_data['desc']
|
|
if self.end:
|
|
commit_data['desc'] = commit_data['desc'] + '\n' + commit_data['branch']
|