mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Remove support for RobotComments, which have been removed from Gerrit.
Bug: 428171766 Change-Id: I38ddbf4a934f80897301d2fd04d8b83a799b1bd7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6690195 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Andy Perelson <ajp@google.com>
This commit is contained in:
@@ -1407,12 +1407,6 @@ def GetChangeComments(host, change):
|
||||
return ReadHttpJsonResponse(CreateHttpConn(host, path))
|
||||
|
||||
|
||||
def GetChangeRobotComments(host, change):
|
||||
"""Gets the line- and file-level robot comments on a change."""
|
||||
path = 'changes/%s/robotcomments' % change
|
||||
return ReadHttpJsonResponse(CreateHttpConn(host, path))
|
||||
|
||||
|
||||
def GetRelatedChanges(host, change, revision='current'):
|
||||
"""Gets the related changes for a given change and revision."""
|
||||
path = 'changes/%s/revisions/%s/related' % (change, revision)
|
||||
|
||||
22
git_cl.py
22
git_cl.py
@@ -2595,24 +2595,16 @@ class Changelist(object):
|
||||
|
||||
def GetCommentsSummary(self, readable=True):
|
||||
# DETAILED_ACCOUNTS is to get emails in accounts.
|
||||
# CURRENT_REVISION is included to get the latest patchset so that
|
||||
# only the robot comments from the latest patchset can be shown.
|
||||
# CURRENT_REVISION was historically included to get the latest patchset
|
||||
# so that only the robot comments from the latest patchset were shown.
|
||||
# Robot comments were removed from Gerrit but this setting was kept to
|
||||
# not change what human comments are shown either. It would be
|
||||
# reasonable to expand this in the future.
|
||||
messages = self._GetChangeDetail(
|
||||
options=['MESSAGES', 'DETAILED_ACCOUNTS', 'CURRENT_REVISION']).get(
|
||||
'messages', [])
|
||||
file_comments = gerrit_util.GetChangeComments(
|
||||
self.GetGerritHost(), self._GerritChangeIdentifier())
|
||||
robot_file_comments = gerrit_util.GetChangeRobotComments(
|
||||
self.GetGerritHost(), self._GerritChangeIdentifier())
|
||||
|
||||
# Add the robot comments onto the list of comments, but only
|
||||
# keep those that are from the latest patchset.
|
||||
latest_patch_set = self.GetMostRecentPatchset()
|
||||
for path, robot_comments in robot_file_comments.items():
|
||||
line_comments = file_comments.setdefault(path, [])
|
||||
line_comments.extend([
|
||||
c for c in robot_comments if c['patch_set'] == latest_patch_set
|
||||
])
|
||||
|
||||
# Build dictionary of file comments for easy access and sorting later.
|
||||
# {author+date: {path: {patchset: {line: url+message}}}}
|
||||
@@ -2631,7 +2623,7 @@ class Changelist(object):
|
||||
for comment in line_comments:
|
||||
tag = comment.get('tag', '')
|
||||
if tag.startswith(
|
||||
'autogenerated') and 'robot_id' not in comment:
|
||||
'autogenerated'):
|
||||
continue
|
||||
key = (comment['author']['email'], comment['updated'])
|
||||
if comment.get('side', 'REVISION') == 'PARENT':
|
||||
@@ -2661,7 +2653,7 @@ class Changelist(object):
|
||||
key = (msg['author']['email'], msg['date'])
|
||||
# Don't bother showing autogenerated messages that don't have associated
|
||||
# file or line comments. this will filter out most autogenerated
|
||||
# messages, but will keep robot comments like those from Tricium.
|
||||
# messages.
|
||||
is_autogenerated = msg.get('tag', '').startswith('autogenerated')
|
||||
if is_autogenerated and not comments.get(key):
|
||||
return None
|
||||
|
||||
@@ -635,9 +635,6 @@ class TestGitCl(unittest.TestCase):
|
||||
mock.patch(
|
||||
'git_cl.gerrit_util.GetChangeComments',
|
||||
lambda *a: self._mocked_call('GetChangeComments', *a)).start()
|
||||
mock.patch(
|
||||
'git_cl.gerrit_util.GetChangeRobotComments',
|
||||
lambda *a: self._mocked_call('GetChangeRobotComments', *a)).start()
|
||||
mock.patch('git_cl.gerrit_util.AddReviewers',
|
||||
lambda *a: self._mocked_call('AddReviewers', *a)).start()
|
||||
mock.patch('git_cl.gerrit_util.SetReview',
|
||||
@@ -3307,8 +3304,6 @@ class TestGitCl(unittest.TestCase):
|
||||
},
|
||||
]
|
||||
}),
|
||||
(('GetChangeRobotComments', 'chromium-review.googlesource.com',
|
||||
'infra%2Finfra~1'), {}),
|
||||
] * 2 + [(('write_json', 'output.json', [{
|
||||
u'date':
|
||||
u'2017-03-16 20:00:41.000000',
|
||||
@@ -3367,118 +3362,6 @@ class TestGitCl(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
0, git_cl.main(['comments', '-i', '1', '-j', 'output.json']))
|
||||
|
||||
@unittest.skipIf(gclient_utils.IsEnvCog(),
|
||||
'not supported in non-git environment')
|
||||
def test_git_cl_comments_robot_comments(self):
|
||||
# git cl comments also fetches robot comments (which are considered a
|
||||
# type of autogenerated comment), and unlike other types of comments,
|
||||
# only robot comments from the latest patchset are shown.
|
||||
scm.GIT.SetConfig('', 'remote.origin.url',
|
||||
'https://x.googlesource.com/infra/infra')
|
||||
gerrit_util.GetChangeDetail.return_value = {
|
||||
'owner': {
|
||||
'email': 'owner@example.com'
|
||||
},
|
||||
'current_revision':
|
||||
'ba5eba11',
|
||||
'revisions': {
|
||||
'deadbeaf': {
|
||||
'_number': 1,
|
||||
},
|
||||
'ba5eba11': {
|
||||
'_number': 2,
|
||||
},
|
||||
},
|
||||
'messages': [
|
||||
{
|
||||
u'_revision_number': 1,
|
||||
u'author': {
|
||||
u'_account_id': 1111084,
|
||||
u'email': u'commit-bot@chromium.org',
|
||||
u'name': u'Commit Bot'
|
||||
},
|
||||
u'date': u'2017-03-15 20:08:45.000000000',
|
||||
u'id': u'f5a6c25ecbd3b3b54a43ae418ed97eff046dc50b',
|
||||
u'message':
|
||||
u'Patch Set 1:\n\nDry run: CQ is trying the patch...',
|
||||
u'tag': u'autogenerated:cq:dry-run'
|
||||
},
|
||||
{
|
||||
u'_revision_number': 1,
|
||||
u'author': {
|
||||
u'_account_id': 123,
|
||||
u'email': u'tricium@serviceaccount.com',
|
||||
u'name': u'Tricium'
|
||||
},
|
||||
u'date': u'2017-03-16 20:00:41.000000000',
|
||||
u'id': u'f5a6c25ecbd3b3b54a43ae418ed97eff046d1234',
|
||||
u'message': u'(1 comment)',
|
||||
u'tag': u'autogenerated:tricium',
|
||||
},
|
||||
{
|
||||
u'_revision_number': 1,
|
||||
u'author': {
|
||||
u'_account_id': 123,
|
||||
u'email': u'tricium@serviceaccount.com',
|
||||
u'name': u'Tricium'
|
||||
},
|
||||
u'date': u'2017-03-16 20:00:41.000000000',
|
||||
u'id': u'f5a6c25ecbd3b3b54a43ae418ed97eff046d1234',
|
||||
u'message': u'(1 comment)',
|
||||
u'tag': u'autogenerated:tricium',
|
||||
},
|
||||
{
|
||||
u'_revision_number': 2,
|
||||
u'author': {
|
||||
u'_account_id': 123,
|
||||
u'email': u'tricium@serviceaccount.com',
|
||||
u'name': u'reviewer'
|
||||
},
|
||||
u'date': u'2017-03-17 05:30:37.000000000',
|
||||
u'tag': u'autogenerated:tricium',
|
||||
u'id': u'f5a6c25ecbd3b3b54a43ae418ed97eff046d4568',
|
||||
u'message': u'(1 comment)',
|
||||
},
|
||||
]
|
||||
}
|
||||
self.calls = [
|
||||
(('GetChangeComments', 'x-review.googlesource.com',
|
||||
'infra%2Finfra~1'), {}),
|
||||
(('GetChangeRobotComments', 'x-review.googlesource.com',
|
||||
'infra%2Finfra~1'), {
|
||||
'codereview.settings': [
|
||||
{
|
||||
u'author': {
|
||||
u'email': u'tricium@serviceaccount.com'
|
||||
},
|
||||
u'updated': u'2017-03-17 05:30:37.000000000',
|
||||
u'robot_run_id': u'5565031076855808',
|
||||
u'robot_id': u'Linter/Category',
|
||||
u'tag': u'autogenerated:tricium',
|
||||
u'patch_set': 2,
|
||||
u'side': u'REVISION',
|
||||
u'message': u'Linter warning message text',
|
||||
u'line': 32,
|
||||
},
|
||||
],
|
||||
}),
|
||||
]
|
||||
expected_comments_summary = [
|
||||
git_cl._CommentSummary(
|
||||
date=datetime.datetime(2017, 3, 17, 5, 30, 37),
|
||||
message=(
|
||||
u'(1 comment)\n\ncodereview.settings\n'
|
||||
u' PS2, Line 32: https://x-review.googlesource.com/c/1/2/'
|
||||
u'codereview.settings#32\n'
|
||||
u' Linter warning message text\n'),
|
||||
sender=u'tricium@serviceaccount.com',
|
||||
autogenerated=True,
|
||||
approval=False,
|
||||
disapproval=False)
|
||||
]
|
||||
cl = git_cl.Changelist(issue=1, branchref='refs/heads/foo')
|
||||
self.assertEqual(cl.GetCommentsSummary(), expected_comments_summary)
|
||||
|
||||
def test_get_remote_url_with_mirror(self):
|
||||
original_os_path_isdir = os.path.isdir
|
||||
|
||||
|
||||
Reference in New Issue
Block a user