git-cl: add --fixed / -x option to upload
This option take the same format as -b / --bug but
spits out "Fixed: #,#" instead of "Bug: #,#".
This CL also looks for fix-, fixed-, and fixes-
branch prefixes and uses those as cue to add "Fixed:"
to the CL description when editing. This is a slight
behavioral change for fix- specifically, as it used
to produce "Bug: " instead.
Bug: monorail:4470
Change-Id: Ib24a1ff33ca3674e53fc5437f459ea5708988290
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1846785
Commit-Queue: Dan Beam <dbeam@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 917024a..0da416d 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -1415,6 +1415,17 @@
title='Title',
change_id='Izzzz')
+ def test_gerrit_upload_force_sets_fixed(self):
+ self._run_gerrit_upload_test(
+ ['-x', '10000', '-f'],
+ u'desc=\n\nFixed: 10000\nChange-Id: Ixxx',
+ [],
+ force=True,
+ expected_upstream_ref='origin/master',
+ fetched_description='desc=\n\nChange-Id: Ixxx',
+ original_title='Initial upload',
+ change_id='Ixxx')
+
def test_gerrit_reviewer_multiple(self):
self.mock(git_cl.gerrit_util, 'GetCodeReviewTbrScore',
lambda *a: self._mocked_call('GetCodeReviewTbrScore', *a))
@@ -2222,6 +2233,34 @@
]
self.assertEqual(0, git_cl.main(['description', '--gerrit']))
+ def test_description_does_not_append_bug_line_if_fixed_is_present(self):
+ current_desc = 'Some.\n\nFixed: 123\nChange-Id: xxx'
+
+ def RunEditor(desc, _, **kwargs):
+ self.assertEquals(
+ '# Enter a description of the change.\n'
+ '# This will be displayed on the codereview site.\n'
+ '# The first line will also be used as the subject of the review.\n'
+ '#--------------------This line is 72 characters long'
+ '--------------------\n'
+ 'Some.\n\nFixed: 123\nChange-Id: xxx',
+ desc)
+ return desc
+
+ self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
+ self.mock(git_cl.Changelist, 'GetDescription',
+ lambda *args: current_desc)
+ self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor)
+
+ self.calls = [
+ ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
+ ((['git', 'config', 'branch.feature.gerritissue'],), '123'),
+ ((['git', 'config', 'rietveld.autoupdate'],), CERR1),
+ ((['git', 'config', 'rietveld.bug-prefix'],), CERR1),
+ ((['git', 'config', 'core.editor'],), 'vi'),
+ ]
+ self.assertEqual(0, git_cl.main(['description', '--gerrit']))
+
def test_description_set_stdin(self):
out = StringIO.StringIO()
self.mock(git_cl.sys, 'stdout', out)