Mastering PR Messages: Why worry about them when there's AI (Part 2)
Tags: programming, opensource, productivity, ai
Published: 2023-12-08 14:41:43

## Content

1. Introduction
2. Scenario
3. PR messages with GitHub Copilot
4. PR messages with CodiumAI
5. Which is better?
6. Conclusion

## Introduction


![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7u66lt1hxk717fahlayz.jpeg)

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](https://dev.to/tecnosam/mastering-pr-messages-how-to-get-your-prs-merged-part-1-19e3), 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.

## Scenario

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.

<br>

Let's head over to the repo and fork it.

![Image of the Repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aovs0up7vs0ak3u23mcp.png)

<br>

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.

<br>

![Here's what the code we will be changing looks like.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzns8gsz683wn7fr15m5.png)

<br>

We clone our fork to our local computer and create a new branch called "feature/subquery-search" using the following commands.

```sh
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".

<br>

![Here's A look at what the function looks like.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ln46g5kzils18jre94rr.png)

<br>

To make things neater, let's create a function called search_for_shows to handle the regular expressions search for us.

<br>

![Image of the search_for_shows function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t85msiuscnrs7nsvq22u.png)

<br>

Finally, here's what the search endpoint looks like now.

<br>

![Image of the search endpoint](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sudsrp067p28mpqec3yd.png)

<br>

Once that has done, we commit our changes and push back to GitHub so we can make our PR.

## PR messages with [GitHub Copilot](https://github.com/features/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](https://docs.github.com/en/copilot/using-github-copilot/getting-started-with-github-copilot). After that, you can ask GitHub Copilot to give you a good PR message based on the changelog.

<br>

![Prompting Copilot chat to write the PR Message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3yr2erdcbkrawvtzolof.png)

<br>

## PR messages with [CodiumAI](https://www.codium.ai/products/git-plugin/)

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).

<br>


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/edoy2bqoh3y3yovhttzx.gif)

<br>

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](https://github.com/Codium-ai/pr-agent/blob/main/INSTALL.md#run-as-a-github-app) on how to get that done.

<br>

![CodiumAI rewriting PR messages like a cha](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/toemhzyollzjgcpj3nun.gif)

<br>

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.


<br>

![Using the /review command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a7co5iypkkyvpp48sv99.png)

<br>

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.

<br>

![Using the /ask command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nssnhdjl26j6y7mfw9bo.png)

<br>

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.


<br>

![using the /improve command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as7bz6itsxv2fu5ltm10.png)

[Here's a link with all the recommendations from CodiumAI](https://github.com/Alfred-Onuada/tv-shows-microservice/pull/2/files/e1b087c3947266252e0f3527b3a139f3937738bd) You also have the option to just commit the changes directly to the pull request. (Pretty cool right?)

<br>

## GitHub Copilot VS CodiumAI's PR Agent

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.

## Conclusion

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.