Need assistance with Gerrit plugin development for automated code review

100 views
Skip to first unread message

谢龙

unread,
Jun 12, 2023, 12:21:07 PM6/12/23
to Repo and Gerrit Discussion
Hi,

I hope this email finds you well. I am currently working on developing a Gerrit plugin that aims to automate code review by listening to patch submissions. However, I'm facing some challenges with the implementation and would greatly appreciate your assistance in resolving them.

Here is a snippet of my code:


@Listen
@Slf4j
public class GerritEventListener implements EventListener {

    @Override
    public void onEvent(Event event) {
        log.info("GerritEventListener works, event:{}", event);
    }

}

Nasser Grainawi

unread,
Jun 12, 2023, 12:23:05 PM6/12/23
to 谢龙, Repo and Gerrit Discussion
On Mon, Jun 12, 2023 at 10:21 AM 谢龙 <xielo...@gmail.com> wrote:
Hi,

I hope this email finds you well. I am currently working on developing a Gerrit plugin that aims to automate code review by listening to patch submissions. However, I'm facing some challenges with the implementation and would greatly appreciate your assistance in resolving them.

Hi! What are the challenges you're having? Also, can you give more context on what you mean by "automate code review"? Is that something like you want to execute specific Gerrit APIs when certain criteria are met?
 

Here is a snippet of my code:


@Listen
@Slf4j
public class GerritEventListener implements EventListener {

    @Override
    public void onEvent(Event event) {
        log.info("GerritEventListener works, event:{}", event);
    }

}

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/9e6e0713-dbfe-4e85-a1b3-99ef36cdad9bn%40googlegroups.com.

谢龙

unread,
Jun 12, 2023, 10:21:56 PM6/12/23
to Nasser Grainawi, Repo and Gerrit Discussion
Thank you for your response. Here's the specific situation: When engineers submit a patch, my automated code review program is able to retrieve the patch information and send it to GPT for assistance with the review process. The review results are then written in the comments.

However, I have been unable to successfully trigger this event during patch submission testing. The "GerritEventListener works" log message is not being printed. I'm uncertain whether there is an error in my code or if additional steps need to be taken.

Nasser Grainawi <nasser....@linaro.org> 于2023年6月13日周二 00:23写道:

谢龙

unread,
Jun 12, 2023, 11:26:17 PM6/12/23
to Nasser Grainawi, Repo and Gerrit Discussion
I have found the problem. The event registration should be done as follows:
      DynamicSet.bind(binder(), EventListener.class).to(GerritEventListener.class);

Previously, I mistakenly wrote it like this:
      bind(EventListener.class).to(GerritEventListener.class).

谢龙 <xielo...@gmail.com> 于2023年6月13日周二 10:21写道:

Daniele Sassoli

unread,
Jun 13, 2023, 5:08:27 AM6/13/23
to 谢龙, Nasser Grainawi, Repo and Gerrit Discussion
On Tue, 13 Jun 2023 at 04:26, 谢龙 <xielo...@gmail.com> wrote:
I have found the problem. The event registration should be done as follows:
      DynamicSet.bind(binder(), EventListener.class).to(GerritEventListener.class);

Previously, I mistakenly wrote it like this:
      bind(EventListener.class).to(GerritEventListener.class).

谢龙 <xielo...@gmail.com> 于2023年6月13日周二 10:21写道:
Thank you for your response. Here's the specific situation: When engineers submit a patch, my automated code review program is able to retrieve the patch information and send it to GPT for assistance with the review process. The review results are then written in the comments.

This seems quite interesting and would be happy to contribute if you're planning on open-sourcing it. I'm sure many people will be looking into doing something similar.

谢龙

unread,
Jun 13, 2023, 6:04:55 AM6/13/23
to Daniele Sassoli, Nasser Grainawi, Repo and Gerrit Discussion
Thank you for your encouragement and interest.
I will endeavor to develop a smaller version and then share it for collaborative improvement : )

Daniele Sassoli <da...@gerritforge.com> 于2023年6月13日周二 17:07写道:

谢龙

unread,
Jun 17, 2023, 4:24:50 AM6/17/23
to Daniele Sassoli, Nasser Grainawi, Repo and Gerrit Discussion
@Daniele Sassoli  I've developed the first version of this plugin and it's now available on GitHub. Feel free to check it out if you're interested.

谢龙 <xielo...@gmail.com> 于2023年6月13日周二 18:04写道:

谢龙

unread,
Jun 17, 2023, 4:27:12 AM6/17/23
to Daniele Sassoli, Nasser Grainawi, Repo and Gerrit Discussion
Reply all
Reply to author
Forward
0 new messages