-
Notifications
You must be signed in to change notification settings - Fork 15
Option to use custom bug fix pattern #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
import re | ||
|
||
from collections import defaultdict | ||
from subprocess import check_output | ||
from subprocess import check_output, CalledProcessError | ||
|
||
|
||
def _run_bash_command(bash_cmd): | ||
|
@@ -20,7 +20,11 @@ def _run_bash_command(bash_cmd): | |
The resulting stdout output. | ||
""" | ||
|
||
stdout = check_output(bash_cmd.split()).decode('utf-8').rstrip('\n') | ||
try: | ||
stdout = check_output(bash_cmd.split()).decode('utf-8').rstrip('\n') | ||
except CalledProcessError as err: | ||
print('Failed to execute bash command: {!r}'.format(str(bash_cmd))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to wrap |
||
exit(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call adding the non-zero exit status |
||
|
||
return stdout | ||
|
||
|
@@ -80,7 +84,7 @@ def get_git_log(commit=None): | |
return stdout | ||
|
||
|
||
def get_bugfix_commits(): | ||
def get_bugfix_commits(pattern=None): | ||
"""Get the commits whose commit messages contain BUG or FIX. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably update this docstring too. |
||
|
||
Returns | ||
|
@@ -89,8 +93,12 @@ def get_bugfix_commits(): | |
A list of commit hashes. | ||
""" | ||
|
||
if pattern is None: | ||
pattern = ("BUG", "FIX") | ||
|
||
# TODO: add option to specify custom bugfix tags | ||
bash_cmd = "git log -i --all --grep BUG --grep FIX --pretty=format:%h" | ||
bash_cmd = "git log -i --all --grep {} --grep {} --pretty=format:%h"\ | ||
.format(pattern[0], pattern[1]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do this in a way that allows for a variable number of bugfix tags, maybe something like:
|
||
|
||
stdout = _run_bash_command(bash_cmd) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
click
lets you specify an option multiple times by passingmultiple=True
. Let's do that so we can accept an arbitrary number of tags, which will be nice.One thing to watch out for though: using
multiple=True
makes the option always return a tuple even if no arguments were passed, so we will need to change our check inget_bugfix_commits
fromif pattern is None
toif len(pattern) == 0
.