ait

Time

AI-Generated Messages from Git Diffs and Logs

This script uses the OpenAI API to generate text based on the outputs of git diff and git log commands. It can be particularly useful for creating pull request descriptions, commit messages, or any other narrative that requires summarizing changes between different branches or commits in a Git repository.

Features

Prerequisites

Installation

Clone the repository and navigate to the directory:

git clone https://github.com/PxaMMaxP/ait
cd your-repository

Install the necessary Python packages:

pip install openai

Usage

Basic Usage

To generate a message based on the current branch’s diff and log against the main branch, simply run:

python ait.py

This will use the default configuration file (ait.config.json) located in the current directory.

Using Custom Configurations

You can specify a different configuration file using the --config option:

python ait.py --config custom_config.json

Shorthand Configuration Selection

Alternatively, if you only provide a keyword, the script will look for a file named ait.<KEYWORD>.config.json in the current directory:

python ait.py --config custom

This command will look for a configuration file named ait.custom.config.

As a fallback, if no configuration file is found, the script will search for it in the user’s home directory under ~\.ait\*.

You can also provide a user wide configuration file by placing it in the ~\.ait\ directory.

Command-Line Options

Example Config Files

See the ait.commit.sample.config.json and ait.pull_request.sample.config.json files for examples of configuration files.

Error Handling

The script will raise an error if the API key is not provided either via the command-line argument or the configuration file.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.