Revolutionizing Commit Messages with AI

In the world of software development, commit messages play a crucial role in tracking changes, understanding the evolution of code, and collaborating effectively within a team. However, writing meaningful commit messages can be a tedious task, often resulting in generic or uninspiring messages. This is where OpenCommit comes into play, aiming to eliminate lame commits with the power of artificial intelligence.

Auto-generate Meaningful Commits in 1 Second

OpenCommit is an innovative tool that leverages AI to automatically generate meaningful commit messages for your code changes. The primary goal is to enhance the quality of commit messages, making them more descriptive and relevant. By doing so, OpenCommit contributes to better code documentation and collaboration.

Getting Started with OpenCommit

Setting up OpenCommit is a breeze, and you can start using it as a command-line interface (CLI) tool. The process involves a few simple steps:

1. Install OpenCommit Globally

   npm install -g opencommit

2. Obtain Your OpenAI API Key

   Get your API key from OpenAI and ensure that you add your payment details to enable API functionality.

3. Set API Key in OpenCommit Config

   oco config set OCO_OPENAI_API_KEY=<your_api_key>

   Your API key is stored locally in the ~/.opencommit config file.

Usage Example

Once OpenCommit is set up, you can use it to generate commit messages for your staged changes. Here’s a quick example:

Stage your changes

git add <files...>

Generate a commit message with OpenCommit

opencommit

Alternatively, you can use the `oco` shortcut:

Stage your changes

git add <files...>

Generate a commit message with OpenCommit using the shortcut

oco

Configuration Options

OpenCommit provides various configuration options to tailor the generated commit messages according to your preferences. These configurations include:

Local per repo configuration

Create a `.env` file in your repository and set OpenCommit config variables such as API key, max response tokens, base path to OpenAI API, description, emoji usage, model selection, language, message template, and prompt module.

OCO_OPENAI_API_KEY=<your OpenAI API token>
OCO_OPENAI_MAX_TOKENS=<max response tokens from OpenAI API>
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
OCO_DESCRIPTION=<postface a message with ~3 sentences description of the changes>
OCO_EMOJI=<boolean, add GitMoji>
OCO_MODEL=<either 'gpt-4', 'gpt-3.5-turbo-16k' (default), 'gpt-3.5-turbo-0613' or 'gpt-3.5-turbo'>
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, default: '$msg'>
OCO_PROMPT_MODULE=<either conventional-commit or @commitlint, default: conventional-commit>

Global Config for All Repos

Set global configurations for OpenCommit, such as the default model and language. But local configurations still take priority, allowing flexibility for specific repository needs.

oco config set OCO_MODEL=gpt-4

Conclusion

OpenCommit is a game-changer in the world of version control. By automating the process of crafting meaningful commit messages, it not only saves time for developers but also contributes to the overall readability and understanding of code repositories. Embrace the power of AI with OpenCommit, and say goodbye to mundane commit messages.

Hope you enjoy that.

Asahi



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム