Categorygithub.com/ohnotnow/diff_message_generator_go
repositorypackage
0.0.14
Repository: https://github.com/ohnotnow/diff_message_generator_go.git
Documentation: pkg.go.dev

# README

Git Diff to Commit Message Generator

This Go program runs git diff to collect changes in a Git repository and then sends the results to the OpenAI API to generate a well-written commit message. It provides an AI-generated commit message that encapsulates the changes made, following best practices for commit messages.

Features

  • Automates commit message generation using OpenAI's API.
  • Reads Git repository changes with git diff.
  • Integrates additional context to create informative and comprehensive commit messages.
  • Offers flexibility in choosing the OpenAI model and custom context.

Requirements

  • Go 1.16 or later
  • An OpenAI API key

Installation

The easiest way is to download a binary for your OS/architecture from the Releases page. If you want to build the code yourself then :

  1. Clone the repository to your local machine:
    git clone https://github.com/ohnotnow/diff_message_generator_go
    
  2. Change into the project directory:
    cd diff_message_generator_go
    
  3. Build the Go program:
    go build gdm.go
    

Configuration

  • OpenAI API Key: Set your OpenAI API key as an environment variable:
    export OPENAI_API_KEY=<YOUR-API-KEY>
    

Usage

To run the program, use the following command:

./gdm --model <MODEL-NAME> [Optionally add some additional context]
  • Model: Specifies the OpenAI model to use (default: gpt-4o-mini).
  • Optional additional context to be added to the prompt sent to OpenAI.

If you do not specify a model, it defaults to gpt-4o-mini. Ensure that you have a valid OpenAI API key set in the environment variable OPENAI_API_KEY.

Output

The output is a well-written commit message based on the git diff result, displayed in the console. You can then use this message to commit your changes in Git.

License

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

Contributing

Contributions are welcome! Please fork this repository and create a pull request with your proposed changes.