Class CommentPorter
A ported comment is a comment which was left on an earlier patchset and is shown on a later patchset. If a comment eligible for porting (e.g. before target patchset) can't be matched to its exact position in the target patchset, we'll map it to its next best location. This can also include a transformation of a line comment into a file comment.
-
Constructor Summary
ConstructorsConstructorDescriptionCommentPorter
(DiffOperations diffOperations, CommentsUtil commentsUtil, com.google.gerrit.server.restapi.change.CommentPorter.Metrics metrics) -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.collect.ImmutableList<HumanComment>
portComments
(ChangeNotes changeNotes, PatchSet targetPatchset, List<HumanComment> comments, List<HumanCommentFilter> filters) Ports the given comments to the target patchset.
-
Constructor Details
-
CommentPorter
@Inject public CommentPorter(DiffOperations diffOperations, CommentsUtil commentsUtil, com.google.gerrit.server.restapi.change.CommentPorter.Metrics metrics)
-
-
Method Details
-
portComments
public com.google.common.collect.ImmutableList<HumanComment> portComments(ChangeNotes changeNotes, PatchSet targetPatchset, List<HumanComment> comments, List<HumanCommentFilter> filters) Ports the given comments to the target patchset.Not all given comments are ported. Only those fulfilling some criteria (e.g. before target patchset) are considered eligible for porting.
The returned comments represent the ported version. They don't bear any indication to which patchset they were ported. This is intentional as the target patchset should be obvious from the API or the used REST resources. The returned comments still have the patchset field filled. It contains the reference to the patchset on which the comment was originally left. That patchset number can vary among the returned comments as all comments before the target patchset are potentially eligible for porting.
The number of returned comments can be smaller (-> only eligible ones are ported!) or larger compared to the provided comments. The latter happens when files appear as copied in the target patchset. In such a situation, the same comment UUID will occur more than once in the returned comments.
- Parameters:
changeNotes
- theChangeNotes
of the change to which the comments belongtargetPatchset
- the patchset to which the comments should be portedcomments
- the original commentsfilters
- additional filters to apply to the comments before porting. Only the remaining comments will be ported.- Returns:
- the ported comments, in no particular order
-