Commit d0f79117 authored by Jonas Termansen's avatar Jonas Termansen Committed by Commit Bot

Support bug prefixes when stripping away empty bug in git-cl-upload.

For instance, if the bug-prefix is set to "b/", git cl upload will offer a
line with "Bug: b/", however it won't get stripped away if it's left blank,
unlike the default "Bug:" line. This change fixes that inconsistency by
also taking the bug-prefix into account when stripping.

Change-Id: Ib6e4d18c1ff52ec77cd1422be15b1e6920332238
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1528972Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Jonas Termansen <sortie@google.com>
parent 57dd17b4
...@@ -3083,8 +3083,8 @@ class ChangeDescription(object): ...@@ -3083,8 +3083,8 @@ class ChangeDescription(object):
] + self._description_lines) ] + self._description_lines)
regexp = re.compile(self.BUG_LINE) regexp = re.compile(self.BUG_LINE)
prefix = settings.GetBugPrefix()
if not any((regexp.match(line) for line in self._description_lines)): if not any((regexp.match(line) for line in self._description_lines)):
prefix = settings.GetBugPrefix()
values = list(_get_bug_line_values(prefix, bug or '')) or [prefix] values = list(_get_bug_line_values(prefix, bug or '')) or [prefix]
if git_footer: if git_footer:
self.append_footer('Bug: %s' % ', '.join(values)) self.append_footer('Bug: %s' % ', '.join(values))
...@@ -3100,7 +3100,9 @@ class ChangeDescription(object): ...@@ -3100,7 +3100,9 @@ class ChangeDescription(object):
# Strip off comments and default inserted "Bug:" line. # Strip off comments and default inserted "Bug:" line.
clean_lines = [line.rstrip() for line in lines if not clean_lines = [line.rstrip() for line in lines if not
(line.startswith('#') or line.rstrip() == "Bug:")] (line.startswith('#') or
line.rstrip() == "Bug:" or
line.rstrip() == "Bug: " + prefix)]
if not clean_lines: if not clean_lines:
DieWithError('No CL description, aborting') DieWithError('No CL description, aborting')
self.set_description(clean_lines) self.set_description(clean_lines)
......
...@@ -964,6 +964,7 @@ class TestGitCl(TestCase): ...@@ -964,6 +964,7 @@ class TestGitCl(TestCase):
if not issue: if not issue:
# Prompting to edit description on first upload. # Prompting to edit description on first upload.
calls += [ calls += [
((['git', 'config', 'rietveld.bug-prefix'],), ''),
((['git', 'config', 'core.editor'],), ''), ((['git', 'config', 'core.editor'],), ''),
((['RunEditor'],), description), ((['RunEditor'],), description),
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment