'git cl issue 0': Remove Change-Id
Although git-cl-upload warns when uploading a new patchset
to a change owned by someone else, if the uploader has run
'git cl issue 0', then git-cl believes they'll be uploading
a new change, so it doesn't bother checking. However, once
the upload begins, Gerrit notices the Change-Id in the commit
message, and instead adds a new patchset to someone else's
review (if the uploader is a committer).
This change introduces some logic to git-cl-issue to also
remove any Change-Id from the commit message when a user
tries to clear the metadata about their branch.
Bug: 741648
Change-Id: I6c7c3b24a7fc09c68220c8200b732fbdf9cf1fd3
Reviewed-on: https://chromium-review.googlesource.com/568267
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index a3b3830..cea2758 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -2647,6 +2647,8 @@
def test_cmd_issue_erase_existing(self):
out = StringIO.StringIO()
self.mock(git_cl.sys, 'stdout', out)
+ self.mock(git_cl.Changelist, 'GetDescription',
+ lambda _: 'This is a description')
self.calls = [
((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
((['git', 'config', 'branch.feature.rietveldissue'],), CERR1),
@@ -2662,6 +2664,27 @@
]
self.assertEqual(0, git_cl.main(['issue', '0']))
+ def test_cmd_issue_erase_existing_with_change_id(self):
+ out = StringIO.StringIO()
+ self.mock(git_cl.sys, 'stdout', out)
+ self.mock(git_cl.Changelist, 'GetDescription',
+ lambda _: 'This is a description\n\nChange-Id: Ideadbeef')
+ self.calls = [
+ ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
+ ((['git', 'config', 'branch.feature.rietveldissue'],), CERR1),
+ ((['git', 'config', 'branch.feature.gerritissue'],), '123'),
+ ((['git', 'commit', '--amend', '-m', 'This is a description\n'],), ''),
+ # Let this command raise exception (retcode=1) - it should be ignored.
+ ((['git', 'config', '--unset', 'branch.feature.last-upload-hash'],),
+ CERR1),
+ ((['git', 'config', '--unset', 'branch.feature.gerritissue'],), ''),
+ ((['git', 'config', '--unset', 'branch.feature.gerritpatchset'],), ''),
+ ((['git', 'config', '--unset', 'branch.feature.gerritserver'],), ''),
+ ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],),
+ ''),
+ ]
+ self.assertEqual(0, git_cl.main(['issue', '0']))
+
def test_cmd_issue_json(self):
out = StringIO.StringIO()
self.mock(git_cl.sys, 'stdout', out)