Crates.io | gai |
lib.rs | gai |
version | 0.1.4 |
source | src |
created_at | 2023-06-10 17:47:09.22683 |
updated_at | 2023-10-11 07:42:44.484348 |
description | Automatically generate commit messages from a git diff using AI |
homepage | https://github.com/dpecos/gai |
repository | https://github.com/dpecos/gai |
max_upload_size | |
id | 887001 |
size | 167,863 |
GAI (Git + AI) is a command-line interface (CLI) tool written in Rust that utilizes OpenAI models to generate informative commit messages from a git diff
by reading from its standard input (stdin). It combines the power of Git with advanced language models to automate the process of creating meaningful and concise commit messages based on the changes made to your Git repository.
git diff
and generate descriptive commit messages.Before using GAI, ensure that you have the following prerequisites installed on your system:
To install GAI, follow these steps:
cargo install gai
Clone the GAI repository:
git clone https://github.com/dpecos/gai.git
Change into the cloned repository directory:
cd gai
Build and install GAI using Cargo:
cargo install --path .
This will build GAI and install it into your system.
GAI requires an OpenAI API key to run. Before using GAI, make sure to set the OPENAI_API_KEY
environment variable with your OpenAI API key.
export OPENAI_API_KEY=<your-openai-api-key>
To use GAI, follow these steps:
Navigate to your Git repository's root directory.
Run the git diff
command to generate the diff of your changes.
Pipe the git diff
output to GAI:
git diff | gai
(Note: you can also pass the diff from your staged changes with git diff --cached
)
GAI will process the input from git diff
using OpenAI models and generate a commit message based on the changes.
Note: GAI reads from the standard input (stdin), so make sure to pipe the git diff
output correctly.
Review the generated commit message and make any necessary adjustments.
Commit your changes using the generated commit message:
git commit -m "$(git diff | gai)"
This will create a new commit with the generated commit message.
An alternative is to define a shell alias that brings everything together:
alias gaic='git diff --cached | gai | git commit -F -'
But if this feels too much of rush, and you'd like to confirm the commit message manually, you can use ays
like this:
alias gaic='git diff --cached | gai | ays --preview "Use this message for the commit?" | git commit -F -'
And this is how your workflow would look like:
Contributions to GAI are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request to the GitHub repository.
Before contributing, please review the Contribution Guidelines for important information.
GAI is licensed under the MIT License. Feel free to use, modify, and distribute this project as per the license terms.
GAI was created by Daniel Pecos Martinez. Special thanks to all the contributors who have helped make this project better.
If you have any questions, suggestions, or feedback, you can reach out to the project maintainer at me@danielpecos.com.
Happy coding!