Accessing patchset comments from plugin

13 views
Skip to first unread message

Igor

unread,
Jan 10, 2018, 10:02:58 AM1/10/18
to Repo and Gerrit Discussion
Hi,

I'm writing a plugin that needs to read patchset comments. It's implemented as a button on change screen (based on a cookbook plugin example). 
Within apply method I can access various properties of the change using GerritApi handle, but for some reason I cannot find patchset comments.
I tried comments(), but it returns only inline comments. When trying info().messages I get null. So I assume I'm missing something.

Here is the code excerpt:

...
@Inject protected GerritApi gApi;

@Override
public String apply(RevisionResource rev, Input input) {
    try {
        Collection<ChangeMessageInfo> messages = gApi.changes().id(rev.getChange().getChangeId()).info().messages;
        if (messages == null) {
            return "Messages is null";
        } else {
            return String.format("Found %s messages", messages.size());
        }
    } catch (RestApiException e) {
        return "ERROR: Cannot read change comments";
    }
}

Thanks in advance,
Igor.
Reply all
Reply to author
Forward
0 new messages