summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlava Shishkin <slavashishkin@gmail.com>2022-04-26 14:14:37 +0300
committerSlava Shishkin <slavashishkin@gmail.com>2022-04-26 14:14:37 +0300
commit1baf5042aa6835664d16610dfcb4a3ffb02140f2 (patch)
tree8d1bdc59f3981defd7a696f67f8cd0202bfb962b
parent5ccece311489e366b017600404a4d163dd5215c2 (diff)
downloadgit-bz-1baf5042aa6835664d16610dfcb4a3ffb02140f2.tar.gz
Added conditions for working with multiline comments
-rwxr-xr-xgit-bz17
1 files changed, 9 insertions, 8 deletions
diff --git a/git-bz b/git-bz
index 3a438e2..f1756cd 100755
--- a/git-bz
+++ b/git-bz
@@ -163,7 +163,7 @@ def git_run(command, *args, **kwargs):
process = Popen(to_run,
stdout=(None if interactive else PIPE),
stderr=(None if interactive else PIPE),
- stdin=(PIPE if (input != None) else None))
+ stdin=(PIPE if (input is not None) else None))
output, error = process.communicate(input)
if process.returncode != 0:
if not quiet and not interactive:
@@ -259,6 +259,8 @@ def get_patch(commit):
def get_body(commit):
body = git.log(commit.id + "^.." + commit.id, pretty="format:%b", _strip=False)
+ if isinstance(body, bytes):
+ body = body.decode()
# Preserve leading space, which tends to be indents, but strip off
# the trailing newline and any other insignificant space at the end.
return body.rstrip()
@@ -929,10 +931,7 @@ def expand_abbreviation(abbrev, l):
def prompt(message):
while True:
- # Using print here could result in Python adding a stray space
- # before the next print
- sys.stdout.write(message + " [yn] ")
- line = sys.stdin.readline().strip()
+ line = input(f"{message} [yn] ")
if line == 'y' or line == 'Y':
return True
elif line == 'n' or line == 'N':
@@ -1575,13 +1574,15 @@ class Bug(object):
# =============
def commit_needs_url(commit, bug_id):
+ body = get_body(commit)
+ if isinstance(body, bytes):
+ body = body.decode()
pat = re.compile(r"(?<!\d)%d(?!\d)" % bug_id)
- return (pat.search(commit.subject) is None and
- pat.search(get_body(commit)) is None)
+ return pat.search(commit.subject) is None and pat.search(body) is None
def check_add_url(commits, bug_id=None, is_add_url=False):
- if bug_id != None:
+ if bug_id is not None:
# We only need to check the commits that we'll add the URL to
commits = [commit for commit in commits if commit_needs_url(commit, bug_id)]