From d0f7911725f31727fe9475c985ba3c9b611cc753 Mon Sep 17 00:00:00 2001 From: Jonas Termansen Date: Fri, 22 Mar 2019 15:28:26 +0000 Subject: [PATCH] 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 Commit-Queue: Jonas Termansen --- git_cl.py | 6 ++++-- tests/git_cl_test.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/git_cl.py b/git_cl.py index face2d48c..136ba15e1 100755 --- a/git_cl.py +++ b/git_cl.py @@ -3083,8 +3083,8 @@ class ChangeDescription(object): ] + 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 @@ class ChangeDescription(object): # 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) diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index f71a5d5dd..63ac18f37 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -964,6 +964,7 @@ class TestGitCl(TestCase): if not issue: # Prompting to edit description on first upload. calls += [ + ((['git', 'config', 'rietveld.bug-prefix'],), ''), ((['git', 'config', 'core.editor'],), ''), ((['RunEditor'],), description), ]