Package com.google.gerrit.server
Class CommentsUtil
- java.lang.Object
-
- com.google.gerrit.server.CommentsUtil
-
public class CommentsUtil extends Object
Utility functions to manipulate Comments.
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.Ordering<CommentInfo>
COMMENT_INFO_ORDER
static com.google.common.collect.Ordering<Comment>
COMMENT_ORDER
-
Method Summary
-
-
-
Field Detail
-
COMMENT_ORDER
public static final com.google.common.collect.Ordering<Comment> COMMENT_ORDER
-
COMMENT_INFO_ORDER
public static final com.google.common.collect.Ordering<CommentInfo> COMMENT_INFO_ORDER
-
-
Method Detail
-
getCommentPsId
public static PatchSet.Id getCommentPsId(Change.Id changeId, Comment comment)
-
newHumanComment
public HumanComment newHumanComment(ChangeNotes changeNotes, CurrentUser currentUser, Timestamp 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
public Optional<HumanComment> getPublishedHumanComment(ChangeNotes notes, Comment.Key key)
-
getPublishedHumanComment
public Optional<HumanComment> getPublishedHumanComment(ChangeNotes notes, String uuid)
-
getDraft
public Optional<HumanComment> getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key)
-
publishedHumanCommentsByChange
public List<HumanComment> publishedHumanCommentsByChange(ChangeNotes notes)
-
robotCommentsByChange
public List<RobotComment> robotCommentsByChange(ChangeNotes notes)
-
getRobotComment
public Optional<RobotComment> getRobotComment(ChangeNotes notes, String uuid)
-
draftByChange
public List<HumanComment> draftByChange(ChangeNotes notes)
-
byPatchSet
public List<HumanComment> byPatchSet(ChangeNotes notes, PatchSet.Id psId)
-
publishedByChangeFile
public List<HumanComment> publishedByChangeFile(ChangeNotes notes, String file)
-
publishedByPatchSet
public List<HumanComment> publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId)
-
robotCommentsByPatchSet
public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId)
-
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)
-
draftByChangeFileAuthor
public List<HumanComment> draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author)
-
draftByChangeAuthor
public List<HumanComment> draftByChangeAuthor(ChangeNotes notes, Account.Id author)
-
putHumanComments
public void putHumanComments(ChangeUpdate update, Comment.Status status, Iterable<HumanComment> comments)
-
putRobotComments
public void putRobotComments(ChangeUpdate update, Iterable<RobotComment> comments)
-
deleteHumanComments
public void deleteHumanComments(ChangeUpdate update, Iterable<HumanComment> comments)
-
deleteCommentByRewritingHistory
public void deleteCommentByRewritingHistory(ChangeUpdate update, Comment.Key commentKey, String newMessage)
-
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
public Collection<org.eclipse.jgit.lib.Ref> getDraftRefs(Change.Id changeId)
Get NoteDb draft refs for a change.Works if NoteDb is not enabled, but the results are not meaningful.
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.
-
-