-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #192
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Issue Prefix | ||
|
||
When migrating to other source code hosting sites, there are cases where a | ||
project maintainer might want to reset their issue tracker and not have old | ||
issue numbers in commit messages referring to the wrong issue. One way around | ||
this is to prefix issue numbers with some other string. | ||
|
||
If migrating to GitHub, this issue prefixing can be paired with GitHub's | ||
autolinking capabilitiy to link back to a different issue tracker: | ||
https://help.github.com/en/github/administering-a-repository/configuring-autolinks-to-reference-external-resources | ||
|
||
To use this plugin, add: | ||
`--plugin=issue_prefix=<some_prefix>` | ||
|
||
Example: | ||
`--plugin=issue_prefix=BB-` | ||
|
||
This will prefix issue numbers with the string `BB-`. Example: `#123` will | ||
change to `#BB-123`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# encoding=UTF-8 | ||
"""__init__.py""" | ||
import re | ||
|
||
def build_filter(args): | ||
return Filter(args) | ||
|
||
class Filter: | ||
def __init__(self, args): | ||
self.prefix = args | ||
|
||
def commit_message_filter(self, commit_data): | ||
for match in re.findall('#[1-9][0-9]+', commit_data['desc']): | ||
commit_data['desc'] = commit_data['desc'].replace( | ||
match, '#%s%s' % (self.prefix, match[1:])) |