Package com.google.gerrit.server
Class CommentsUtil
java.lang.Object
com.google.gerrit.server.CommentsUtil
Utility functions to manipulate Comments.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.google.common.collect.Ordering<CommentInfo>
static final com.google.common.collect.Ordering<Comment>
-
Method Summary
Modifier and TypeMethodDescriptionstatic FixSuggestion
createFixSuggestionFromInput
(FixSuggestionInfo fixSuggestionInfo) static com.google.common.collect.ImmutableList<FixSuggestion>
createFixSuggestionsFromInput
(List<FixSuggestionInfo> fixSuggestionInfos) void
deleteCommentByRewritingHistory
(ChangeUpdate update, Comment.Key commentKey, String newMessage) void
deleteHumanComments
(ChangeUpdate update, Iterable<HumanComment> comments) Optional<org.eclipse.jgit.lib.ObjectId>
determineCommitId
(Change change, PatchSet patchset, short side) Determines the SHA-1 of the commit referenced by the (change, patchset, side) triple.static String
extractMessageId
(String tag) static PatchSet.Id
getCommentPsId
(Change.Id changeId, Comment comment) getPublishedHumanComment
(ChangeNotes notes, Comment.Key key) getPublishedHumanComment
(ChangeNotes notes, String uuid) getRobotComment
(ChangeNotes notes, String uuid) static void
linkCommentsToChangeMessages
(List<? extends CommentInfo> comments, List<ChangeMessage> changeMessages, boolean skipAutoGeneratedMessages) This method populates the "changeMessageId" field of the comments parameter based on timestamp matching.newHumanComment
(ChangeNotes changeNotes, CurrentUser currentUser, Instant when, String path, PatchSet.Id psId, short side, String message, Boolean unresolved, String parentUuid, List<FixSuggestion> fixSuggestions) newRobotComment
(ChangeContext ctx, String path, PatchSet.Id psId, short side, String message, String robotId, String robotRunId) publishedByPatchSet
(ChangeNotes notes, PatchSet.Id psId) void
putHumanComments
(ChangeUpdate update, Comment.Status status, Iterable<HumanComment> comments) void
putRobotComments
(ChangeUpdate update, Iterable<RobotComment> comments) robotCommentsByChange
(ChangeNotes notes) robotCommentsByPatchSet
(ChangeNotes notes, PatchSet.Id psId) void
setCommentCommitId
(Comment c, Change change, PatchSet ps) static FixReplacement
toFixReplacement
(FixReplacementInfo fixReplacementInfo) static List<FixReplacement>
toFixReplacements
(List<FixReplacementInfo> fixReplacementInfos)
-
Field Details
-
COMMENT_ORDER
-
COMMENT_INFO_ORDER
-
-
Method Details
-
getCommentPsId
-
extractMessageId
-
newHumanComment
public HumanComment newHumanComment(ChangeNotes changeNotes, CurrentUser currentUser, Instant when, String path, PatchSet.Id psId, short side, String message, Boolean unresolved, String parentUuid, List<FixSuggestion> fixSuggestions) -
newRobotComment
public RobotComment newRobotComment(ChangeContext ctx, String path, PatchSet.Id psId, short side, String message, String robotId, String robotRunId) -
getPublishedHumanComment
-
getPublishedHumanComment
-
publishedHumanCommentsByChange
-
robotCommentsByChange
-
getRobotComment
-
publishedByPatchSet
-
robotCommentsByPatchSet
-
linkCommentsToChangeMessages
public static void linkCommentsToChangeMessages(List<? extends CommentInfo> comments, List<ChangeMessage> changeMessages, boolean skipAutoGeneratedMessages) This method populates the "changeMessageId" field of the comments parameter based on timestamp matching. The comments objects will be modified.Each comment will be matched to the nearest next change message in timestamp
- Parameters:
comments
- the list of commentschangeMessages
- list of change messages
-
putHumanComments
public void putHumanComments(ChangeUpdate update, Comment.Status status, Iterable<HumanComment> comments) -
putRobotComments
-
deleteHumanComments
-
deleteCommentByRewritingHistory
public void deleteCommentByRewritingHistory(ChangeUpdate update, Comment.Key commentKey, String newMessage) -
setCommentCommitId
-
determineCommitId
public Optional<org.eclipse.jgit.lib.ObjectId> determineCommitId(Change change, PatchSet patchset, short side) Determines the SHA-1 of the commit referenced by the (change, patchset, side) triple.- Parameters:
change
- the change to which the commit belongspatchset
- the patchset to which the commit belongsside
- the side indicating which commit of the patchset to take. 1 is the patchset commit, 0 the parent commit (or auto-merge for changes representing merge commits); -x the xth parent commit of a merge commit- Returns:
- the commit SHA-1 or an empty
Optional
if the side isn't available for the given change/patchset - Throws:
com.google.gerrit.exceptions.StorageException
- if the SHA-1 is unavailable for an unknown reason
-
sort
-
createFixSuggestionsFromInput
public static com.google.common.collect.ImmutableList<FixSuggestion> createFixSuggestionsFromInput(List<FixSuggestionInfo> fixSuggestionInfos) -
createFixSuggestionFromInput
-
toFixReplacements
-
toFixReplacement
-