- PR messages with GitHub Copilot
- PR messages with CodiumAI
- Which is better?
Let's face it. We're developers. We all want to ship fast. When that new feature is requested or that issue is raised, we want to get it checked out ASAP and focus on other things. We hate the extras; standups, emails, testing. We want to focus on writing the code.
In the last article, we looked at the qualities of a good PR message and how to write one. Crafting the perfect PR message takes a lot of work. But what if you don't have to do it yourself?
Today, we've observed a boom in generative AI and LLMs (Large Language Models). We have generative AI models like GPT-4, DALL-E, Stable DIffusion, LLaMA, and more. We've also seen tools that use these models to solve problems and automate tasks like never before. If you're reading this, you have probably used ChatGPT at some point in time to do things that would take you hours in seconds.
In this article, we will be exploring how we can take advantage of some of these tools to help us write better PR messages and allow us to focus on what truly matters, the code.
To illustrate how we can let AI handle our PR messages, I'm going to be using an open-source project written by a good friend of mine (Alfred) on Microservices; a simple illustration of how to build, deploy, and scale (locally) microservices using Docker and Nginx.
Let's head over to the repo and fork it.
It's a system that helps you keep track of popular TV shows. I'm going to be making changes to one of the microservices called "search-service" because it's written in my favorite programming language (Python). "search-service" handles searching for TV shows using a search query.
We clone our fork to our local computer and create a new branch called "feature/subquery-search" using the following commands.
git clone https://github.com/your-username/tv-shows-microservice
git branch feature/subquery-search
git checkout feature/subquery-search
We're going to be making a PR to enhance the search service. If you take a look at the code, you will observe that it takes in a search parameter, and searches for tv-shows with that parameter using regular expressions. What happens when what you searched doesn't match any of the TV shows?
We'd also like to return some shows that closely match. A simple way to do this is to break down the search query into different queries and search for those instead. For example, if a user searches for "The Walking Nun", our algorithm will also search for "The Walking", "The Nun", "Walking Nun", "The", "Walking", and "Nun".
To make things neater, let's create a function called search_for_shows to handle the regular expressions search for us.
Finally, here's what the search endpoint looks like now.
Once that has done, we commit our changes and push back to GitHub so we can make our PR.
PR messages with GitHub Copilot
One of the tools we can use to help us create our PR message is GitHub Copilot. GitHub Copilot is an AI-powered peer programmer developed by GitHub. It has recently launched a new feature called GitHub Copilot Chat on VS Code To set up GitHub Copilot, you can check this link. After that, you can ask GitHub Copilot to give you a good PR message based on the changelog.
PR messages with CodiumAI
Another tool to structure your PR message is CodiumAI's PR Agent. I recommend CodiumAI's PR Agent for a couple of reasons.
CodiumAI's PR Agent is easy to integrate. You don't need to install CodiumAI on VS Code (though that option is also available).
You can mention the CodiumAI's PR Agent in the comment section of the Pull Request. it automatically makes the necessary changes to the title and description. To use this feature, you will need to add CodiumAI either as a GitHub App or GitHub Action in your repository to make it work. You can check out this guide on how to get that done.
CodiumAI works on both sides of the table. It's not just a great tool for writing good PR messages, but it's also a great tool for reviewing the PRs of your teammates. With the CodiumAI command "/review", you get to see an analysis of the branch's changelog, including things like a general summary of the changes, how long it will take you to go through the PR, the type of PR, and suggestions on the PR. So even if your teammates didn't use CodiumAI to structure their PR messages, you can use CodiumAI to review the PRs.
CodiumAI also provides an "/ask" command which lets you ask questions about the PR and what has changed. Think of this as having ChatGPT inside the PR.
You can ask any questions about the code and what has changed. You also get an "/improve" command that shows code suggestions for the PR.
Here's a link with all the recommendations from CodiumAI You also have the option to just commit the changes directly to the pull request. (Pretty cool right?)
In this article, we have discussed two AI tools that can assist us in creating our PR messages. The question now arises as to which one should we use.
GitHub Copilot is an excellent tool for generating code, as it is its primary function. It is a pair programmer AI trained on all open-source code repositories on GitHub, making it extremely powerful for coding tasks. However, its strength in writing effective PR messages may not be as comprehensive or tailored specifically for PR needs.
CodiumAI's PR Agent, on the other hand, specializes in structuring PR messages. It automatically adjusts titles and descriptions based on the content of the PR. Since this AI agent is designed specifically for PRs, it is easier to work with and has more commands that help in other aspects of code collaboration.
In conclusion, AI-powered tools like CodiumAI's PR Agent and GitHub Copilot can help us write better PR messages and save us time. With these tools, we can focus on writing quality code and let the AI handle the tedious tasks of structuring and reviewing PR messages. Consider using one of these AI-powered tools to help you out next time you're creating a PR message.