シュッと opencommit でコミットメッセージを書いてもらう

ちゃっす(/・ω・)/



Git のコミットメッセージって書くのめんどくさいよね~(/・ω・)/

tweak やら test やら hoge やらになりがち

ので、それを AI にやってもらいましょ~という opencommit をひょんなことからシュッと触ったので書き残しておくのだ☆



コミットメッセージのツールとしては aicommits がまぁ有名でござんすが、長らくメンテされてないので新しいモデル(gpt-3.5-turbo-16k) なんかが使えないんですなぁ( ・ω・)



はい、ってなわけで opencommit のチュートリアルを見ながらシュッと触ってみる。



とりあえずいんすとぉぉーーーーる!!

npm install -g opencommit

そして OPENAI_API_KEY を設定である

oco config set OCO_OPENAI_API_KEY=<your_api_key>

設定は `~/.opencommit` に保存されるみたい

んで、あとは雑に

oco

でおけ~(/・ω・)/

$ oco
┌  open-commit
│                                                                                                                                                                                           
◇  1 staged files:                                                                                                                                                                          
  README.md
│
◇  📝 Commit message generated
│
└  Generated commit message:
——————————————————
docs(README.md): add README.md file with project overview, features, installation instructions, usage, configuration, and contribution guidelines

This commit adds a README.md file to the project. The README provides an overview of the project, its main features, installation instructions, usage guidelines, configuration options, and contribution guidelines. The README is written in both English and Japanese to cater to a wider audience. The README aims to provide a clear understanding of the project's purpose and basic usage.
——————————————————

│
◇  Confirm the commit message?
│  Yes
│
└  ✔ Successfully committed

│
└  [main ab037e3] docs(README.md): add README.md file with project overview, features, installation instructions, usage, configuration, and contribution guidelines
 1 file changed, 60 insertions(+), 1 deletion(-)
 rewrite README.md (100%)

│
◇  Do you want to run `git push`?
│  Yes
│
◇  ✔ Successfully pushed all commits to origin

みたいな感じでなるでござんす(/・ω・)/



設定としてはこんなのあるよ

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>


デフォルトだと 'gpt-3.5-turbo-16k' を使うので 

$ oco config set OCO_MODEL=gpt-3.5-turbo-0613

みたいな感じで変更しておくといいかも(/・ω・)/


4k トークン超えるような修正だとエラーになっちゃうのでその時は 16k モデルとか使うんだぞ☆


実際に適当な修正をコミットしてみた

てすと



まぁ、詳細は GitHub のページをよく読んでもろて(/・ω・)/



ということでシュッと書いたのでおしまい。

この記事が気に入ったらサポートをしてみませんか?