Pull Request Descriptor
Pull requests are an integral part of collaborative software development. They allow developers to review code changes before merging them into the main codebase. Creating informative and concise pull request descriptions can be a time-consuming task, especially when dealing with large or complex changes. This is where GenAI comes in, streamlining the process with a smart script that generates pull request descriptions automatically. 🚀
Script Metadata
The script
function is used to set up the script’s metadata. It’s the first thing you’ll notice, and here’s what each property means:
title
: This is the name of the script, which is “Pull Request Descriptor.”description
: A brief explanation of what the script does.temperature
: Sets the creativity level for the AI model. A lower temperature means less creativity, and0.5
is a balanced choice.system.safety...
injects safety rules to the system message to ensure the AI model is not producing harmful or protected content.
Gathering Changes with Git
The script captures the difference between the current branch and the defaultBranch
.
Defining the Git Diff Output
Here, def
is used to define a variable called GIT_DIFF
that holds the changes from the git diff command. It specifies that the content is in diff
format and allows up to 20000
tokens (a measure of content length for the AI model).
Generating the Pull Request Description
The template literal, denoted by $
, is where the AI model is given a prompt to generate the pull request description. The instructions are clearly laid out: summarize the changes without going into details and make the description easy to understand by using bullet points and emojis.
Running the Script
To use this script, you need the GenAIScript CLI installed. If you haven’t installed it yet, please refer to the installation guide.
Once you have the CLI set up, run the following command:
Adding the -prd
flag will automatically update the pull request description on github as well.