git-ai 0.1.0

A git extension to help you write better commit messages.
docs.rs failed to build git-ai-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: git-ai-1.1.0

Git AI Rust

Overview

Git AI uses ChatGPT and git hook to generate commit messages based on the staged files. Leave the commit message empty and let Git AI do the work for you!

Installation

Pre-Built Binaries

  1. cargo binstall cargo-binstall
  2. cargo binstall git-ai

From Source

  1. Ensure Rust and Cargo are installed on your system.
  2. Clone the Git AI repository: git clone https://github.com/oleander/git-ai
  3. Change to the project directory: cd git-ai.
  4. Build the hook: cargo build --release --bin git-ai-hook
  5. Build & install the binary: cargo install --path . --bin git-ai

Usage

  • Install the binary as per the instructions above.
  • Use git ai hook install to set up the Git hook.
  • Set the OpenAI API key with git-ai config set openapi-api-key <api-key>.

CLI Options

Configuration

Use git-ai config set followed by:

  • api-key <api-key>: Set the OpenAI API key.
  • max-tokens <max-tokens>: Set the maximum characters for git diff passed to OpenAI (default is 5000).
  • timeout <timeout>: Set the maximum time in seconds to wait for OpenAI's response (default is 30).
  • language <language>: Choose the model language (default is en).

Hooks

Use git-ai hook followed by:

  • install: Install the Git hook.
  • uninstall: Uninstall the Git hook.

Testing

Execute cargo test to run the test suite.

License

This project is under the MIT License. For more details, see the LICENSE file.

Pre-Publish Checklist

  • Decide on an appropriate name for the binary.
  • Update the README with installation and testing instructions.
  • Ensure continuous integration (CI) passes.
    • Look into ways to simplify the CI process.
  • Define and document configuration options.
  • Implement a feature where CTRL-C resets the terminal.
  • Change the command-line interface (CLI) to use subcommands:
    • git ai hook install
    • git ai hook uninstall
  • Allow proper configuration
    • With validation
    • Fallback values
    • Using environment variables
  • Get rid of the main.rs as binary
  • Move logic from main.rs into sep: config.rs
  • Test against stable & nightly Rust on both macOS and Linux
  • Publish the crate to crates.io