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 TypeMethodDescriptionvoid
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.draftByChangeAuthor
(ChangeNotes notes, Account.Id author) draftByPatchSetAuthor
(PatchSet.Id psId, Account.Id author, ChangeNotes notes) static String
extractMessageId
(String tag) static PatchSet.Id
getCommentPsId
(Change.Id changeId, Comment comment) Collection<org.eclipse.jgit.lib.Ref>
getDraftRefs
(Change.Id changeId) Get NoteDb draft refs for a change.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) newRobotComment
(ChangeContext ctx, String path, PatchSet.Id psId, short side, String message, String robotId, String robotRunId) publishedByChangeFile
(ChangeNotes notes, String file) 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)
-
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) -
newRobotComment
public RobotComment newRobotComment(ChangeContext ctx, String path, PatchSet.Id psId, short side, String message, String robotId, String robotRunId) -
getPublishedHumanComment
-
getPublishedHumanComment
-
publishedHumanCommentsByChange
-
robotCommentsByChange
-
getRobotComment
-
publishedByChangeFile
-
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
-
draftByPatchSetAuthor
public List<HumanComment> draftByPatchSetAuthor(PatchSet.Id psId, Account.Id author, ChangeNotes notes) -
draftByChangeAuthor
-
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
-
getDraftRefs
Get NoteDb draft refs for a change.This is just a simple ref scan, so the results may potentially include refs for zombie draft comments. A zombie draft is one which has been published but the write to delete the draft ref from All-Users failed.
- Parameters:
changeId
- change ID.- Returns:
- raw refs from All-Users repo.
-
sort
-