Commit 889677c0 authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

git cl: now fully use project~changenum when querying Gerrit.

R=ehmaldonado

Bug: 876910
Change-Id: Ibc631bf049440d158de757da0a225ed28f892891
Reviewed-on: https://chromium-review.googlesource.com/1194314Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent 03e0ed26
...@@ -2604,20 +2604,23 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2604,20 +2604,23 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
return data['revisions'][current_rev]['commit']['message'] return data['revisions'][current_rev]['commit']['message']
def UpdateDescriptionRemote(self, description, force=False): def UpdateDescriptionRemote(self, description, force=False):
if gerrit_util.HasPendingChangeEdit(self._GetGerritHost(), self.GetIssue()): if gerrit_util.HasPendingChangeEdit(
self._GetGerritHost(), self._GerritChangeIdentifier()):
if not force: if not force:
confirm_or_exit( confirm_or_exit(
'The description cannot be modified while the issue has a pending ' 'The description cannot be modified while the issue has a pending '
'unpublished edit. Either publish the edit in the Gerrit web UI ' 'unpublished edit. Either publish the edit in the Gerrit web UI '
'or delete it.\n\n', action='delete the unpublished edit') 'or delete it.\n\n', action='delete the unpublished edit')
gerrit_util.DeletePendingChangeEdit(self._GetGerritHost(), gerrit_util.DeletePendingChangeEdit(
self.GetIssue()) self._GetGerritHost(), self._GerritChangeIdentifier())
gerrit_util.SetCommitMessage(self._GetGerritHost(), self.GetIssue(), gerrit_util.SetCommitMessage(
self._GetGerritHost(), self._GerritChangeIdentifier(),
description, notify='NONE') description, notify='NONE')
def AddComment(self, message, publish=None): def AddComment(self, message, publish=None):
gerrit_util.SetReview(self._GetGerritHost(), self.GetIssue(), gerrit_util.SetReview(
self._GetGerritHost(), self._GerritChangeIdentifier(),
msg=message, ready=publish) msg=message, ready=publish)
def GetCommentsSummary(self, readable=True): def GetCommentsSummary(self, readable=True):
...@@ -2625,7 +2628,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2625,7 +2628,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
messages = self._GetChangeDetail( messages = self._GetChangeDetail(
options=['MESSAGES', 'DETAILED_ACCOUNTS']).get('messages', []) options=['MESSAGES', 'DETAILED_ACCOUNTS']).get('messages', [])
file_comments = gerrit_util.GetChangeComments( file_comments = gerrit_util.GetChangeComments(
self._GetGerritHost(), self.GetIssue()) self._GetGerritHost(), self._GerritChangeIdentifier())
# Build dictionary of file comments for easy access and sorting later. # Build dictionary of file comments for easy access and sorting later.
# {author+date: {path: {patchset: {line: url+message}}}} # {author+date: {path: {patchset: {line: url+message}}}}
...@@ -2691,10 +2694,12 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2691,10 +2694,12 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
return summary return summary
def CloseIssue(self): def CloseIssue(self):
gerrit_util.AbandonChange(self._GetGerritHost(), self.GetIssue(), msg='') gerrit_util.AbandonChange(
self._GetGerritHost(), self._GerritChangeIdentifier(), msg='')
def SubmitIssue(self, wait_for_merge=True): def SubmitIssue(self, wait_for_merge=True):
gerrit_util.SubmitChange(self._GetGerritHost(), self.GetIssue(), gerrit_util.SubmitChange(
self._GetGerritHost(), self._GerritChangeIdentifier(),
wait_for_merge=wait_for_merge) wait_for_merge=wait_for_merge)
def _GetChangeDetail(self, options=None, no_cache=False): def _GetChangeDetail(self, options=None, no_cache=False):
...@@ -3279,7 +3284,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -3279,7 +3284,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
} }
labels = {'Commit-Queue': vote_map[new_state]} labels = {'Commit-Queue': vote_map[new_state]}
notify = False if new_state == _CQState.DRY_RUN else None notify = False if new_state == _CQState.DRY_RUN else None
gerrit_util.SetReview(self._GetGerritHost(), self.GetIssue(), gerrit_util.SetReview(
self._GetGerritHost(), self._GerritChangeIdentifier(),
labels=labels, notify=notify) labels=labels, notify=notify)
def CannotTriggerTryJobReason(self): def CannotTriggerTryJobReason(self):
......
...@@ -2130,7 +2130,12 @@ class TestGitCl(TestCase): ...@@ -2130,7 +2130,12 @@ class TestGitCl(TestCase):
((['git', 'config', 'branch.feature.gerritissue'],), '123'), ((['git', 'config', 'branch.feature.gerritissue'],), '123'),
((['git', 'config', 'branch.feature.gerritserver'],), ((['git', 'config', 'branch.feature.gerritserver'],),
'https://chromium-review.googlesource.com'), 'https://chromium-review.googlesource.com'),
((['SetReview', 'chromium-review.googlesource.com', 123, ((['git', 'config', 'branch.feature.merge'],), 'refs/heads/master'),
((['git', 'config', 'branch.feature.remote'],), 'origin'),
((['git', 'config', 'remote.origin.url'],),
'https://chromium.googlesource.com/infra/infra.git'),
((['SetReview', 'chromium-review.googlesource.com',
'infra%2Finfra~123',
{'Commit-Queue': vote}, notify],), ''), {'Commit-Queue': vote}, notify],), ''),
] ]
...@@ -3218,7 +3223,8 @@ class TestGitCl(TestCase): ...@@ -3218,7 +3223,8 @@ class TestGitCl(TestCase):
'origin/master'), 'origin/master'),
((['git', 'config', 'remote.origin.url'],), ((['git', 'config', 'remote.origin.url'],),
'https://chromium.googlesource.com/infra/infra'), 'https://chromium.googlesource.com/infra/infra'),
(('SetReview', 'chromium-review.googlesource.com', 10, 'msg', None), (('SetReview', 'chromium-review.googlesource.com', 'infra%2Finfra~10',
'msg', None),
None), None),
] ]
self.assertEqual(0, git_cl.main(['comment', '--gerrit', '-i', '10', self.assertEqual(0, git_cl.main(['comment', '--gerrit', '-i', '10',
...@@ -3328,7 +3334,8 @@ class TestGitCl(TestCase): ...@@ -3328,7 +3334,8 @@ class TestGitCl(TestCase):
}, },
] ]
}), }),
(('GetChangeComments', 'chromium-review.googlesource.com', 1), { (('GetChangeComments', 'chromium-review.googlesource.com',
'infra%2Finfra~1'), {
'/COMMIT_MSG': [ '/COMMIT_MSG': [
{ {
'author': {'email': u'reviewer@example.com'}, 'author': {'email': u'reviewer@example.com'},
......
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