ChatGPT meets Gerrit or: How I Learned to Stop Worrying and Love the AI Assistants – Medium


Sign in

Sign in
Patrizio Gelosi
Follow

Listen
Share
Sooner or later, it was bound to happen.
And here you are now, the nightmare has come true: ChatGPT has found its way onto your Gerrit server!
It’s there to guide your programming dos and don’ts, obsess over the finer points, and persistently instruct you, not unlike a Sheldon-esque figure.
…or not?
Actually, not at all.
In fact, using ChatGPT from Gerrit is similar to handling any other powerful tool — it’s more likely to be a dream rather than a nightmare, as long as it’s utilized effectively.
Gerrit is a web-based code review and project management tool for Git repositories. It facilitates collaborative coding by allowing developers to submit their changes to a central server, where others can review, discuss, and ultimately approve the changes before they are merged into the project. This process enables multiple eyes to scrutinize every piece of code.
At Amarula, we extensively utilize Gerrit for our development processes, leveraging its robust code review and collaboration features. In light of its features, we concluded that the pairing of Gerrit and ChatGPT was a match already in the making. In our relentless quest for enhanced code quality and improved project management efficiency, we believe that incorporating ChatGPT into Gerrit can refine the review process and introduce an extra dimension of AI-powered intelligence.
As a Virtual Gerrit User, ChatGPT should be empowered to
Talking about tools, the thin line that separates a dream from a nightmare is Control.
Bearing this key principle in mind, it is essential that Gerrit administrators have the capability to selectively enable the ChatGPT review function for particular projects, users, groups, and topics.
The reins of control are tightly held by the developers, as shown in the following workflow:
Alternatively, the process can also begin when developers use the Gerrit UI to start any conversation with ChatGPT on their own, whether it’s a general discussion or based on a specific section of a Patch Set code.
The so-designed Gerrit plugin is available as Open Source project at https://github.com/amarula/chatgpt-code-review-gerrit-plugin/.
This initiative is not just a mere experiment. It’s a full-fledged implementation being rigorously tested in the crucible of real-world, production environments. This real-time testing scenario provides us with a golden opportunity to refine the integration, informed by practical feedback and demands for functionality enhancements.
We realized that it was the right time to move to production. Let’s take a look at the outcome.
ChatGPT, acting as a vigilant overseer, reviews PatchSets of selected Gerrit projects as they arrive. This feature ensures that each submission undergoes a preliminary AI-driven analysis, setting a high standard of quality and coherence right from the start.
Behind the scenes, the path towards enhancing the quality of ChatGPT’s responses was achieved through meticulous prompt engineering. This significant progression involved more than just fine-tuning algorithms; it focused on understanding the delicate dynamics of developer interactions and tailoring the responses to align with these nuances.
An additional feature allows for examining the congruence of the commit messages with the Patch Sets’ changes, ensuring that the narrative of the commit aligns with the actual modifications made.
ChatGPT goes beyond being just a tool, acting more like a virtual colleague. It’s ready to respond to user inquiries, offering suggestions, and clarifying any doubts. This function is akin to having an additional team member, one that’s always available to provide insights and clarifications, much like a knowledgeable human peer.
The ability to start conversations with ChatGPT directly from an inline comment adds a layer of dynamism to the interaction. Users can request reviews on specific parts of the code, extending even beyond the current Patch Set, or ask for improvement suggestions. This feature essentially brings an on-demand code review assistant into the workflow, available at the click of a button.
In the following example, the author inquires further about implementing a change recommended by ChatGPT, showcasing the feature’s interactive and responsive capabilities.
In the example showcased next, ChatGPT is queried about a different implementation approach on a code segment that isn’t directly related to the changes in the Patch Set.
The verbosity level can be further increased by specifically requesting multiple alternatives and code examples.
It is also possible to submit broader inquiries about the entire Patch Set.
Last but certainly not least, we give utmost importance to security and privacy.
Recognizing scenarios where code confidentiality is paramount, we’ve introduced a new configuration option (gptFullFileReview) which, when set to false, restricts the code reviewed by ChatGPT to only the changes made, without including the entire file. This feature ensures that sensitive information remains within the confines of the organization, thus safeguarding intellectual property and adhering to privacy standards.
Our exploration of the integration of ChatGPT into Gerrit has highlighted several key points:
By integrating ChatGPT into Gerrit, we aim to enhance code quality, streamline project management, and introduce AI-driven intelligence into the software development lifecycle. This integration is a step towards a more efficient, collaborative, and intelligent coding environment, highlighting our commitment to innovation and excellence in software development.
For anyone interested in testing the plugin, a version of this article including a Quickstart giude can be found at https://wiki.amarulasolutions.com/opensource/chatgpt-gerrit.html


Help
Status
About
Careers
Blog
Privacy
Terms
Text to speech
Teams

source

Jesse
https://playwithchatgtp.com