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/+/1528972
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Jonas Termansen <sortie@google.com>
diff --git a/git_cl.py b/git_cl.py
index face2d4..136ba15 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -3083,8 +3083,8 @@
] + self._description_lines)
regexp = re.compile(self.BUG_LINE)
+ prefix = settings.GetBugPrefix()
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]
if git_footer:
self.append_footer('Bug: %s' % ', '.join(values))
@@ -3100,7 +3100,9 @@
# Strip off comments and default inserted "Bug:" line.
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:
DieWithError('No CL description, aborting')
self.set_description(clean_lines)