mirror of
https://github.com/frej/fast-export.git
synced 2026-02-17 18:16:46 +01:00
Add branch_name_in_commit plugin
This commit is contained in:
@@ -145,8 +145,9 @@ class Filter:
|
||||
#Or don't pass, if you want to do some init code here
|
||||
```
|
||||
|
||||
Beyond the boilerplate initialization, you can see the one of the
|
||||
defined filter methods in the [dos2unix](./plugins/dos2unix) plugin.
|
||||
Beyond the boilerplate initialization, you can see the two different
|
||||
defined filter methods in the [dos2unix](./plugins/dos2unix) and
|
||||
[branch_name_in_commit](./plugins/branch_name_in_commit) plugins.
|
||||
|
||||
```
|
||||
commit_data = {'branch': branch, 'parents': parents, 'author': author, 'desc': desc}
|
||||
|
||||
10
plugins/branch_name_in_commit/README.md
Normal file
10
plugins/branch_name_in_commit/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## Branch Name in Commit Message
|
||||
|
||||
Mercurial has a much stronger notion of branches than Git,
|
||||
and some parties may not wish to lose the branch information
|
||||
during the migration to Git. You can use this plugin to either
|
||||
prepend or append the branch name from the mercurial
|
||||
commit into the commit message in Git.
|
||||
|
||||
To use the plugin, add
|
||||
`--plugin branch_name_in_commit=(start|end)`.
|
||||
14
plugins/branch_name_in_commit/__init__.py
Normal file
14
plugins/branch_name_in_commit/__init__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
def build_filter(args):
|
||||
return Filter(args)
|
||||
|
||||
class Filter:
|
||||
def __init__(self, args):
|
||||
if not args in ['start','end']:
|
||||
raise Exception('Cannot have branch name anywhere but start and end')
|
||||
self.pos = args
|
||||
|
||||
def commit_message_filter(self,commit_data):
|
||||
if self.pos == 'start':
|
||||
commit_data['desc'] = commit_data['branch'] + '\n' + commit_data['desc']
|
||||
if self.pos == 'end':
|
||||
commit_data['desc'] = commit_data['desc'] + '\n' + commit_data['branch']
|
||||
Reference in New Issue
Block a user