【Github Copilot】コミットメッセージはAIが考える時代!?
2024-01-24
azblob://2024/01/24/eyecatch/2024-01-24-github-copilot-generate-commit-message-000.jpg

X(旧: Twitter)でVisual Studio Code(以下、VSCと表記)とGithub Copilot(以下、Copilotと表記)を使えば、コメントを自動生成してくれるポストを見つけ、少し興味を持ったのでメモ程度に書いています。

Copilotでコミットメッセージを生成する方法

それでは、Copilotにコメントを書いてもらいます。

ステップは簡単で、

  1. 対象ファイルをステージングエリアに追加
  2. VSCのSource Controlタブでのアイコンをクリック

以上、2ステップで簡単にコミットメッセージを生成します。

検証

コミットメッセージの精度を評価するため、以下3パターンを検証します。

1. flutter createで作成したプロジェクトファイル全てをステージングエリアに追加

生成結果

Add new files and update existing files

2. main.dartを変更

変更前

 void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

変更後

   void _incrementCounter() {
    setState(() {
      _counter--;
    });
  }

コメントを削除し、加算から減算に変更。

生成結果

Decrement counter in _incrementCounter method

3. linuxディレクトリを削除

生成結果

Remove unused Flutter files

評価

1と3はファイルの追加や削除で作業範囲自体は大きいですが、内容は単純なため、「追加(or 削除)したんだな」と人間なら判断すると思います。Copilotは察することができないため、1と3は曖昧な表現になりますが、適切な粒度で追加した2は人間と同程度(もしくはそれ以上)の内容を生成しました。 (※ 筆者の独断と偏見でコミットメッセージを評価しています)

結論

Copilotにコミットメッセージを生成してもらう場合、適切な粒度でステージングエリアに追加する!

感想

筆者がコミットメッセージを書いた場合、

  • 1: add: Flutterプロジェクトの作成及び追加
  • 2: edit: 加算から減算に変更
  • 3: delete: linuxディレクトリを削除

と書くため、2しかCopilotと意気投合しませんでしたw

以上、「gitの操作はCLIでしょ!」というCLI派閥の筆者がGUI派閥に寝返るかもしれないVSC上の便利機能でした!

azblob://2024/04/12/eyecatch/2024-04-12-gemini-1.5-000.jpg
2024/04/11
AI/Machine Learning