Add support for line comment ranges
This tells gerrit to highlight a range of lines. Change-Id: I7628bede2220c27f880c688ea5520ea86665f093
This commit is contained in:
parent
bcfcf4f396
commit
f4c486c968
|
@ -696,9 +696,17 @@ change, set the **zuul.file_comments** value. For example:
|
|||
message: "Line too long"
|
||||
- line: 82
|
||||
message: "Line too short"
|
||||
- line: 119
|
||||
message: "This block is indented too far."
|
||||
range:
|
||||
start_line: 117
|
||||
start_character: 0
|
||||
end_line: 119
|
||||
end_character: 37
|
||||
|
||||
Not all reporters currently support line comments; in these cases,
|
||||
reporters will simply ignore this data.
|
||||
Not all reporters currently support line comments (or all of the
|
||||
features of line comments); in these cases, reporters will simply
|
||||
ignore this data.
|
||||
|
||||
.. _build_status:
|
||||
|
||||
|
|
|
@ -273,7 +273,8 @@ class FakeGerritChange(object):
|
|||
self.patchsets.append(d)
|
||||
self.data['submitRecords'] = self.getSubmitRecords()
|
||||
|
||||
def addComment(self, filename, line, message, name, email, username):
|
||||
def addComment(self, filename, line, message, name, email, username,
|
||||
comment_range=None):
|
||||
comment = {
|
||||
'file': filename,
|
||||
'line': int(line),
|
||||
|
@ -284,6 +285,8 @@ class FakeGerritChange(object):
|
|||
},
|
||||
'message': message,
|
||||
}
|
||||
if comment_range:
|
||||
comment['range'] = comment_range
|
||||
self.comments.append(comment)
|
||||
|
||||
def getPatchsetCreatedEvent(self, patchset):
|
||||
|
@ -703,7 +706,8 @@ class FakeGerritConnection(gerritconnection.GerritConnection):
|
|||
for comment in commentlist:
|
||||
change.addComment(filename, comment['line'],
|
||||
comment['message'], 'Zuul',
|
||||
'zuul@example.com', self.user)
|
||||
'zuul@example.com', self.user,
|
||||
comment.get('range'))
|
||||
if 'submit' in action:
|
||||
change.setMerged()
|
||||
if message:
|
||||
|
|
|
@ -1041,8 +1041,12 @@ class TestInRepoConfig(ZuulTestCase):
|
|||
'message': 'Job non-existent-job not defined',
|
||||
'reviewer': {'email': 'zuul@example.com',
|
||||
'name': 'Zuul',
|
||||
'username': 'jenkins'}}
|
||||
)
|
||||
'username': 'jenkins'},
|
||||
'range': {'end_character': 0,
|
||||
'end_line': 9,
|
||||
'start_character': 2,
|
||||
'start_line': 5},
|
||||
})
|
||||
|
||||
def test_dynamic_config_non_existing_job_in_template(self):
|
||||
"""Test that requesting a non existent job fails"""
|
||||
|
|
|
@ -41,7 +41,12 @@ class GerritReporter(BaseReporter):
|
|||
continue
|
||||
existing_comments = ret.setdefault(context.path, [])
|
||||
existing_comments.append(dict(line=mark.end_line,
|
||||
message=err.short_error))
|
||||
message=err.short_error,
|
||||
range=dict(
|
||||
start_line=mark.line + 1,
|
||||
start_character=mark.column,
|
||||
end_line=mark.end_line,
|
||||
end_character=mark.end_column)))
|
||||
return ret
|
||||
|
||||
def report(self, item):
|
||||
|
|
Loading…
Reference in New Issue