Files
Fast-Export/plugins/branch_name_in_commit/__init__.py
chrisjbillington 8efbb57822 Add additional options to branch_name_in_commit plugin
- 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.
2020-02-07 20:48:49 -05:00

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']