Add Gerrit-Comment-In-Reply-To footer
Change-Id: I7860838077cb303331a50ac2855441534bb26d10
This commit is contained in:
parent
b8aca3593f
commit
d8c493109a
@ -244,6 +244,17 @@ In comment emails, the has-labels footer states whether label votes had
|
||||
been posted in that notification using "Yes" or "No", for
|
||||
example `Gerrit-HasLabels: No`.
|
||||
|
||||
[[Gerrit-Comment-In-Reply-To]]Gerrit-Comment-In-Reply-To::
|
||||
|
||||
In comment emails, a comment-in-reply-to footer is present for each
|
||||
account who has a comment that is replied-to in that set of comments.
|
||||
For example, to apply a filter to Gerrit messages in which your own diff
|
||||
comments are responded to, you might search for the following:
|
||||
|
||||
----
|
||||
Gerrit-Comment-In-Reply-To: User Name <user@example.com>
|
||||
----
|
||||
|
||||
GERRIT
|
||||
------
|
||||
Part of link:index.html[Gerrit Code Review]
|
||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.common.data.FilenameComparator;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.common.errors.NoSuchEntityException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
@ -243,6 +244,34 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
return groups;
|
||||
}
|
||||
|
||||
/** Get the set of accounts whose comments have been replied to in this email. */
|
||||
private HashSet<Account.Id> getReplyAccounts() {
|
||||
HashSet<Account.Id> replyAccounts = new HashSet<>();
|
||||
|
||||
// Track visited parent UUIDs to avoid cycles.
|
||||
HashSet<String> visitedUuids = new HashSet<>();
|
||||
|
||||
for (Comment comment : inlineComments) {
|
||||
visitedUuids.add(comment.key.uuid);
|
||||
|
||||
// Traverse the parent relation to the top of the comment thread.
|
||||
Comment current = comment;
|
||||
while (current.parentUuid != null && !visitedUuids.contains(current.parentUuid)) {
|
||||
Optional<Comment> optParent = getParent(current);
|
||||
if (!optParent.isPresent()) {
|
||||
// There is a parent UUID, but it cannot be loaded, break from the comment thread.
|
||||
break;
|
||||
}
|
||||
|
||||
Comment parent = optParent.get();
|
||||
replyAccounts.add(parent.author.getId());
|
||||
visitedUuids.add(current.parentUuid);
|
||||
current = parent;
|
||||
}
|
||||
}
|
||||
return replyAccounts;
|
||||
}
|
||||
|
||||
private String getCommentLinePrefix(Comment comment) {
|
||||
int lineNbr = comment.range == null ? comment.lineNbr : comment.range.startLine;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -497,6 +526,10 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
footers.add("Gerrit-Comment-Date: " + getCommentTimestamp());
|
||||
footers.add("Gerrit-HasComments: " + (hasComments ? "Yes" : "No"));
|
||||
footers.add("Gerrit-HasLabels: " + (labels.isEmpty() ? "No" : "Yes"));
|
||||
|
||||
for (Account.Id account : getReplyAccounts()) {
|
||||
footers.add("Gerrit-Comment-In-Reply-To: " + getNameEmailFor(account));
|
||||
}
|
||||
}
|
||||
|
||||
private String getLine(PatchFile fileInfo, short side, int lineNbr) {
|
||||
|
Loading…
Reference in New Issue
Block a user