leemeichin / gpt-commit

Generate conventional commit messages using GPT.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GPT-Commit: Generate Conventional Commit Messages with GPT in Emacs

Screenshot

GPT-Commit is an Emacs package that automatically generates conventional commit messages using the GPT (Generative Pre-trained Transformer) model from OpenAI.

Table of Contents

Installation

Via MELPA

If you have MELPA configured, you can easily install gpt-commit from within Emacs by running:

M-x package-install RET gpt-commit RET

Manual

To install this package manually, clone this repository and add the following to your .emacs or init.el:

(add-to-list 'load-path "/path/to/gpt-commit")
(require 'gpt-commit)

Configuration

  1. Set OpenAI API Key: You will need an API key from OpenAI to use the GPT model. Set the key like this:
(setq gpt-commit-openai-key "YOUR_OPENAI_API_KEY")
  1. Set GPT Model Name (Optional): By default, it uses the gpt-3.5-turbo model. If you wish to use a different model, you can set it like this:
(setq gpt-commit-model-name "YOUR_PREFERRED_MODEL_NAME")
  1. Add Hook: Add the gpt-commit-message function to the git-commit-setup-hook to automatically generate commit messages when the commit message editor starts:
(require 'gpt-commit)
(add-hook 'git-commit-setup-hook 'gpt-commit-message)

Usage

Once you have configured gpt-commit, it will automatically generate a commit message using the GPT model whenever you perform a Git commit. You can accept the message by saving and closing the editor, or you can modify the message as needed.

Please note that using the OpenAI API might incur costs, and there might be usage limitations. Be aware of the OpenAI pricing and policy before extensive use.

Examples

In our blog post, we've shared real-world examples of how GPT-Commit works with different types of commits. These examples are based on actual commits from the Angular project. Here's a quick overview:

  • Documentation Updates: GPT-Commit accurately identifies that the commit is related to documentation updates and provides more specific information about the update in the commit message.
  • Bug Fixes: GPT-Commit identifies a bug fix and provides a clear description of the fix in the commit message.
  • Feature Addition: GPT-Commit correctly identifies the change as a feature addition and provides a clear description of the new feature in the commit message.
  • Dependency Update: GPT-Commit correctly identifies a dependency update and specifies the packages and version number in the commit message.
  • GitHub Action Update: GPT-Commit accurately recognizes the commit as a CI configuration update and provides a clear description of the update in the commit message.

For more detailed examples and comparisons with original commit messages, please check out the blog post.

Benefits

GPT-Commit offers several benefits to developers:

  • Time-saving: GPT-Commit automates the task of writing commit messages, saving developers' time.
  • Consistency: GPT-Commit generates commit messages in a consistent format, making the commit history easier to read and understand.
  • Focus on coding: With GPT-Commit taking care of commit messages, developers can focus more on coding.

Feedback

We're always looking to improve GPT-Commit and we'd love to hear your thoughts. If you've used GPT-Commit, please share your experiences. If you haven't, we encourage you to give it a try and let us know what you think. You can provide feedback by creating an issue in our GitHub repository.

License

GPT-Commit is licensed under the GNU General Public License v3.0.

About

Generate conventional commit messages using GPT.

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 94.5%Language:Makefile 5.5%