#commit-message #git-commit #conventional-commits #commit #git-diff #chatgpt #cli-tool

app turbocommit

A CLI tool to create commit messages with OpenAI GPT models

39 releases (15 breaking)

new 0.16.1 Mar 21, 2024
0.15.5 Feb 4, 2024
0.14.1 Nov 10, 2023
0.12.1 Jul 10, 2023
0.8.4 Mar 29, 2023

#6 in #git-diff

Download history 3/week @ 2024-01-29 10/week @ 2024-02-19 16/week @ 2024-02-26 9/week @ 2024-03-11 279/week @ 2024-03-18

306 downloads per month

MIT license

245KB
1.5K SLoC

Rust 1K SLoC // 0.0% comments Python 197 SLoC Jinja2 75 SLoC

turbocommit

Crates.io Crates.io Crates.io

turbocommit is a CLI tool written in Rust that generates commit messages in accordance with the Conventional Commits specification. It uses the git diff to create commit messages that accurately reflect the changes made to a repository.

Installation

turbocommit can be easily installed with Cargo, Rust's package manager. Simply run the following command:

cargo install turbocommit

Please note that in order to use turbocommit, you will need to set the OPENAI_API_KEY environment variable. This API key is required to use the OpenAI gpt-3.5-turbo16k language model, which is used by turbocommit to generate commit messages.

Usage

When you have staged some changes, you can run the turbocommit (I recommend making a tc symlink)

Generating Conventional Commits with turbocommit

Short Long Description Default
-n Number of choices to generate 1
-m --model Model to use gpt-3.5-turbo16k
-d --dry-run Dry run. Will not ask AI for completions
-p --print-once Will not print tokens as they are generated
-t Temperature (t |0.0 < t < 2.0|) 1.0
-f Frequency penalty (f |-2.0 < f < 2.0|) 0.0

Available Models

Name Context Window Cost Input Cost Output
gpt-3.5-turbo 4096 0.0015 0.002
gpt-3.5-turbo-16k 16384 0.003 0.004
gpt-4 8192 0.03 0.06
gpt-4-32k 32768 0.06 0.12

Handling Long git diff

In some cases, the git diff for staged changes may be too long to fit within the 16384 (or 4096) token limit enforced by the language model, which turbocommit uses to generate commit messages. When this happens, turbocommit will prompt you with a message indicating that the git diff is too long.

To address this, turbocommit provides a list of all staged files and ask you to select any number of them. The tool will then generate a new git diff that includes only the changes from the selected files. If the resulting git diff plus the system prompt is still too long, turbocommit will repeat the process until the git diff is short enough to be processed by the AI model.

This allows you to generate conventional commit messages with turbocommit while ensuring that the git diff is short enough to be processed by the AI model.

Getting Help with turbocommit

To get help with using turbocommit, you can use the -h or --help option

$ turbocommit --help

This will display the help message with information on how to use the tool.

Dependencies

~32–50MB
~769K SLoC