トップ «前の日記(2025/11/26 (水) ) 最新 編集 RSS feed

HsbtDiary


2025/11/27 (木) [長年日記]

copilot に commit メッセージを書かせるやつ

https://diary.hatenablog.jp/entry/2025/11/23/233725 を見て便利だなあと copilot に置き換えて使ってみたものの、stdout に実行後の統計情報が出て邪魔だな〜となっていたところに同僚が魔改造バージョンを社内で共有してくれたので、自分が必要な箇所だけピックアップした。

ac = "!f() { COMMITMSG=$(copilot -p 'Generate ONLY a one-line Git commit message in English, using imperative mood, summarizing what was changed and why, based strictly on the contents of `git diff --cached`. Do not add explanation or a body. Output only the commit summary line.' 2>/dev/null | sed '/^$/d' | tail -n 1); git commit -S -m \"$COMMITMSG\" -e; }; f"

要は最後の行だけを取り出すって感じで。大体のケースでこれでええやろ、ってメッセージが出るので、なんて書くかな、と1-2分悩むと言うことがなくなってめちゃくちゃ捗る。

copilot に pull-request の初回入力を書かせるやつ

これで git commit に情報を入れられるなら gh pr create にだってきるんじゃね?と調べたらできた。

function git-apr
  set -l target (git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | string replace 'refs/remotes/origin/' '')

  set -l title (copilot -p "Generate ONLY a concise English PR title (imperative mood) based on \`git diff origin/$target...HEAD\`. Output only the title line." 2>/dev/null | sed '/^$/d' | tail -n 1)

  set -l body (copilot -p "Generate a detailed English PR description in Markdown format, explaining 'What' and 'Why', based on \`git diff origin/$target...HEAD\`. Do not include the title." 2>/dev/null | string collect)

  gh pr create --web --title "$title" --body "$body"
end

fish 用なので bash にしたい人は LLM にでもやらせてください。body の prompt がイマイチで、いかにも AI に書かせたなあと言う人間が読む気がしない文章しか生成しないのでもうちょい簡潔にしやがれ、など入れるのが良さそう。

ただ、こんなレベルのものでも pr 画面を開いてから、「うーん」と3-5分悩むと言うことがなくなったのでめちゃくちゃ捗る。便利便利。

モンベルのフック付きカラビナが便利

https://www.gizmodo.jp/2025/07/306495.html で見かけていいな、と思っていたフックにもなるカラビナをモンベルの店舗に行ったらたまたま見かけたので妻の分も含めて一緒に買って使っている。

実際使ってみると、マシンを入れているような重さでもゴムで滑り止めしてちゃんと支えてくれるし、ついでに色々引っ掛けても良い、って感じで大変便利。今年のベストバイトップ5に入るかも、と言うくらい便利。

オンラインショップにはないっぽいので、店舗に行って見かけたら買う、で良さそう。