VScode自动生成commit message

3,078 阅读1分钟

效果演示

在最新版的vscode中,当你的GitLens升级到最新版以后,你会在你的侧边栏中,发现这样一个按钮

image.png

当你点击这个按钮后,就会帮你生成当前修改代码的commit message,类似于如下效果

image.png

使用方式

  • 确保VScode升级到最新版本
  • 确保GitLens插件升级到最新版本
  • 需要openAI API-key(因为使用的gpt-3.5-turbo生成的)

只要你有了API-key以后,其实就可以直接生成了,但是它生成的全部都是英文的,不太符合我的需求,所以我们就需要写自己的prompt来修改。

  1. 打开vscode的设置页面,在搜索栏中输入:Generate Commit Message Prompt,显示如下效果:

image.png 2. 在输入框中,输入自己的prompt

Now, please generate a commit message.
Make sure it includes an accurate and informative subject line that succinctly summarizes the key points of the changes, and does not exceed 50 characters.
The template is `[<Type>] (<Scope>): <Brief Description>`,
where Type and Scope are in English, while Description are in Chinese.

最后就可以开心的一键生成提交代码了,妈妈再也不用担心我不知道怎么写commit message了


写在最后:确保自己可以正常访问openAI官网,确保自己有apikey