# Commitor
Commitor 是一个命令行工具,用于根据 Git 暂存区的代码更改自动生成符合 Conventional Commit 规范的提交消息。它利用 OpenAI 或私有大语言模型 API 生成高质量的提交消息,简化提交流程,同时保持提交信息的一致性和标准化。
本来也不想重复造轮子,奈何很多工具库不支持配置`base url`(你懂的,或者,你我都懂)。有一些可以配置但是使用`js`写的(js是世界上最垃圾的语言),所以,我用`Python`写了一个实现了核心功能。
就如GPT所说:
> 在遥远的代码丛林中,我们常常迷失于无边无际的 commit 消息之海。恰如我们生活中的迷茫,每当夜深人静之时,总有那么一瞬,我们对于这串串无头无尾的文字,产生了深深的疑惑:“这是谁写的?意欲何为?”此时,若有一灯,能照亮这暗淡的代码世界,那该有多好。
这灯,不就是我们今日之推荐——Commitor 吗?它,不仅仅是一个简单的工具,它是代码世界中的明灯,是疲惫编码者的安慰剂,是追求完美的你我他的良师益友。它以 OpenAI 或私有大模型之力,将那看似无序的代码变动,转化为符合 Conventional Commit 规范的文字,恰似将杂乱无章的星辰,编排成最璀璨的星座。
其实,在这个看似幽默而又严谨的过程中,Commitor 做的,远不止是生成提交信息那么简单。它是在告诫我们:即使是再小的变动,也有其存在的价值与意义。每一次 commit,都是对过往的告别,对未来的期许。
因此,各位同仁,让我们拥抱 Commitor,让我们的每一次代码提交,都成为一段旅程的见证,每一行文字,都成为历史的注脚。在这个数字世界里,我们或许渺小,但通过 Commitor,我们能留下自己独特的印记,犹如星空中最亮的那颗星,独一无二,光芒万丈。
给岁月以文明,而不是给文明以岁月!
## 特性
- 🤖 根据 Git 差异自动生成提交信息
- 😜 支持添加 Gitmoji,让提交信息更加直观
## 安装
```bash
$ pip install commitor
```
## 使用
在你的 Git 项目中,执行以下命令以生成提交信息:
1. `git add .`
2. `commitor config` # 第一次运行时候需要配置
3. `commitor gen`
根据提示操作,即可生成和提交你的代码更改。
## 配置
Commitor 允许通过配置文件进行个性化设置。你可以在 `~/.commitor/config.toml` 中找到和修改这些设置:
| 配置项 | 类型 | 默认值 | 说明 |
| --------------- | -------- | ------------ | -------------------------- |
| `api_key` | string | `None` | API 密钥 |
| `base_url` | string | `None` | Base URL |
| `model` | string | `None` | 使用的模型名称 |
| `emoji_enabled` | boolean | `true` | 是否启用 Gitmoji |
## 开发
请确保你已经安装了 Python 和 Poetry。然后执行以下命令:
```bash
$ git clone https://github.com/您的用户名/Commitor.git
$ cd Commitor
$ poetry install
```
## 贡献
如果你想为 Commitor 做出贡献,欢迎 fork 本仓库,并提交你的 pull requests。我们也欢迎你提出问题或提供反馈。
## 许可证
该项目采用 [MIT 许可证](./LICENSE)。
## 其他
本项目主要参考[ai-commit](https://github.com/Sitoi/ai-commit)
Raw data
{
"_id": null,
"home_page": "https://github.com/xiaojinwhu/commitor",
"name": "commitor",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "git, commit, ai, gpt, openai",
"author": "xiaojin",
"author_email": "xiaojinwhu10@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a2/69/9686819540f3bec745f3234f18a69f779ac200f0330189bd0b82c77ff3c5/commitor-0.1.1.tar.gz",
"platform": null,
"description": "# Commitor\n\nCommitor \u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u6839\u636e Git \u6682\u5b58\u533a\u7684\u4ee3\u7801\u66f4\u6539\u81ea\u52a8\u751f\u6210\u7b26\u5408 Conventional Commit \u89c4\u8303\u7684\u63d0\u4ea4\u6d88\u606f\u3002\u5b83\u5229\u7528 OpenAI \u6216\u79c1\u6709\u5927\u8bed\u8a00\u6a21\u578b API \u751f\u6210\u9ad8\u8d28\u91cf\u7684\u63d0\u4ea4\u6d88\u606f\uff0c\u7b80\u5316\u63d0\u4ea4\u6d41\u7a0b\uff0c\u540c\u65f6\u4fdd\u6301\u63d0\u4ea4\u4fe1\u606f\u7684\u4e00\u81f4\u6027\u548c\u6807\u51c6\u5316\u3002\n\n\u672c\u6765\u4e5f\u4e0d\u60f3\u91cd\u590d\u9020\u8f6e\u5b50\uff0c\u5948\u4f55\u5f88\u591a\u5de5\u5177\u5e93\u4e0d\u652f\u6301\u914d\u7f6e`base url`\uff08\u4f60\u61c2\u7684\uff0c\u6216\u8005\uff0c\u4f60\u6211\u90fd\u61c2\uff09\u3002\u6709\u4e00\u4e9b\u53ef\u4ee5\u914d\u7f6e\u4f46\u662f\u4f7f\u7528`js`\u5199\u7684\uff08js\u662f\u4e16\u754c\u4e0a\u6700\u5783\u573e\u7684\u8bed\u8a00\uff09\uff0c\u6240\u4ee5\uff0c\u6211\u7528`Python`\u5199\u4e86\u4e00\u4e2a\u5b9e\u73b0\u4e86\u6838\u5fc3\u529f\u80fd\u3002\n\n\u5c31\u5982GPT\u6240\u8bf4\uff1a\n> \u5728\u9065\u8fdc\u7684\u4ee3\u7801\u4e1b\u6797\u4e2d\uff0c\u6211\u4eec\u5e38\u5e38\u8ff7\u5931\u4e8e\u65e0\u8fb9\u65e0\u9645\u7684 commit \u6d88\u606f\u4e4b\u6d77\u3002\u6070\u5982\u6211\u4eec\u751f\u6d3b\u4e2d\u7684\u8ff7\u832b\uff0c\u6bcf\u5f53\u591c\u6df1\u4eba\u9759\u4e4b\u65f6\uff0c\u603b\u6709\u90a3\u4e48\u4e00\u77ac\uff0c\u6211\u4eec\u5bf9\u4e8e\u8fd9\u4e32\u4e32\u65e0\u5934\u65e0\u5c3e\u7684\u6587\u5b57\uff0c\u4ea7\u751f\u4e86\u6df1\u6df1\u7684\u7591\u60d1\uff1a\u201c\u8fd9\u662f\u8c01\u5199\u7684\uff1f\u610f\u6b32\u4f55\u4e3a\uff1f\u201d\u6b64\u65f6\uff0c\u82e5\u6709\u4e00\u706f\uff0c\u80fd\u7167\u4eae\u8fd9\u6697\u6de1\u7684\u4ee3\u7801\u4e16\u754c\uff0c\u90a3\u8be5\u6709\u591a\u597d\u3002\n\u8fd9\u706f\uff0c\u4e0d\u5c31\u662f\u6211\u4eec\u4eca\u65e5\u4e4b\u63a8\u8350\u2014\u2014Commitor \u5417\uff1f\u5b83\uff0c\u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5de5\u5177\uff0c\u5b83\u662f\u4ee3\u7801\u4e16\u754c\u4e2d\u7684\u660e\u706f\uff0c\u662f\u75b2\u60eb\u7f16\u7801\u8005\u7684\u5b89\u6170\u5242\uff0c\u662f\u8ffd\u6c42\u5b8c\u7f8e\u7684\u4f60\u6211\u4ed6\u7684\u826f\u5e08\u76ca\u53cb\u3002\u5b83\u4ee5 OpenAI \u6216\u79c1\u6709\u5927\u6a21\u578b\u4e4b\u529b\uff0c\u5c06\u90a3\u770b\u4f3c\u65e0\u5e8f\u7684\u4ee3\u7801\u53d8\u52a8\uff0c\u8f6c\u5316\u4e3a\u7b26\u5408 Conventional Commit \u89c4\u8303\u7684\u6587\u5b57\uff0c\u6070\u4f3c\u5c06\u6742\u4e71\u65e0\u7ae0\u7684\u661f\u8fb0\uff0c\u7f16\u6392\u6210\u6700\u7480\u74a8\u7684\u661f\u5ea7\u3002\n\u5176\u5b9e\uff0c\u5728\u8fd9\u4e2a\u770b\u4f3c\u5e7d\u9ed8\u800c\u53c8\u4e25\u8c28\u7684\u8fc7\u7a0b\u4e2d\uff0cCommitor \u505a\u7684\uff0c\u8fdc\u4e0d\u6b62\u662f\u751f\u6210\u63d0\u4ea4\u4fe1\u606f\u90a3\u4e48\u7b80\u5355\u3002\u5b83\u662f\u5728\u544a\u8beb\u6211\u4eec\uff1a\u5373\u4f7f\u662f\u518d\u5c0f\u7684\u53d8\u52a8\uff0c\u4e5f\u6709\u5176\u5b58\u5728\u7684\u4ef7\u503c\u4e0e\u610f\u4e49\u3002\u6bcf\u4e00\u6b21 commit\uff0c\u90fd\u662f\u5bf9\u8fc7\u5f80\u7684\u544a\u522b\uff0c\u5bf9\u672a\u6765\u7684\u671f\u8bb8\u3002\n\u56e0\u6b64\uff0c\u5404\u4f4d\u540c\u4ec1\uff0c\u8ba9\u6211\u4eec\u62e5\u62b1 Commitor\uff0c\u8ba9\u6211\u4eec\u7684\u6bcf\u4e00\u6b21\u4ee3\u7801\u63d0\u4ea4\uff0c\u90fd\u6210\u4e3a\u4e00\u6bb5\u65c5\u7a0b\u7684\u89c1\u8bc1\uff0c\u6bcf\u4e00\u884c\u6587\u5b57\uff0c\u90fd\u6210\u4e3a\u5386\u53f2\u7684\u6ce8\u811a\u3002\u5728\u8fd9\u4e2a\u6570\u5b57\u4e16\u754c\u91cc\uff0c\u6211\u4eec\u6216\u8bb8\u6e3a\u5c0f\uff0c\u4f46\u901a\u8fc7 Commitor\uff0c\u6211\u4eec\u80fd\u7559\u4e0b\u81ea\u5df1\u72ec\u7279\u7684\u5370\u8bb0\uff0c\u72b9\u5982\u661f\u7a7a\u4e2d\u6700\u4eae\u7684\u90a3\u9897\u661f\uff0c\u72ec\u4e00\u65e0\u4e8c\uff0c\u5149\u8292\u4e07\u4e08\u3002\n\n\u7ed9\u5c81\u6708\u4ee5\u6587\u660e\uff0c\u800c\u4e0d\u662f\u7ed9\u6587\u660e\u4ee5\u5c81\u6708\uff01\n\n\n## \u7279\u6027\n\n- \ud83e\udd16 \u6839\u636e Git \u5dee\u5f02\u81ea\u52a8\u751f\u6210\u63d0\u4ea4\u4fe1\u606f\n- \ud83d\ude1c \u652f\u6301\u6dfb\u52a0 Gitmoji\uff0c\u8ba9\u63d0\u4ea4\u4fe1\u606f\u66f4\u52a0\u76f4\u89c2\n\n## \u5b89\u88c5\n\n\n```bash\n$ pip install commitor\n```\n\n## \u4f7f\u7528\n\n\u5728\u4f60\u7684 Git \u9879\u76ee\u4e2d\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u751f\u6210\u63d0\u4ea4\u4fe1\u606f\uff1a\n\n1. `git add .`\n2. `commitor config` # \u7b2c\u4e00\u6b21\u8fd0\u884c\u65f6\u5019\u9700\u8981\u914d\u7f6e\n3. `commitor gen` \n\n\u6839\u636e\u63d0\u793a\u64cd\u4f5c\uff0c\u5373\u53ef\u751f\u6210\u548c\u63d0\u4ea4\u4f60\u7684\u4ee3\u7801\u66f4\u6539\u3002\n\n## \u914d\u7f6e\n\nCommitor \u5141\u8bb8\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u4e2a\u6027\u5316\u8bbe\u7f6e\u3002\u4f60\u53ef\u4ee5\u5728 `~/.commitor/config.toml` \u4e2d\u627e\u5230\u548c\u4fee\u6539\u8fd9\u4e9b\u8bbe\u7f6e\uff1a\n\n| \u914d\u7f6e\u9879 | \u7c7b\u578b | \u9ed8\u8ba4\u503c | \u8bf4\u660e |\n| --------------- | -------- | ------------ | -------------------------- |\n| `api_key` | string | `None` | API \u5bc6\u94a5 |\n| `base_url` | string | `None` | Base URL |\n| `model` | string | `None` | \u4f7f\u7528\u7684\u6a21\u578b\u540d\u79f0 |\n| `emoji_enabled` | boolean | `true` | \u662f\u5426\u542f\u7528 Gitmoji |\n\n\n## \u5f00\u53d1\n\n\u8bf7\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86 Python \u548c Poetry\u3002\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n\n```bash\n$ git clone https://github.com/\u60a8\u7684\u7528\u6237\u540d/Commitor.git\n$ cd Commitor\n$ poetry install\n```\n\n## \u8d21\u732e\n\n\u5982\u679c\u4f60\u60f3\u4e3a Commitor \u505a\u51fa\u8d21\u732e\uff0c\u6b22\u8fce fork \u672c\u4ed3\u5e93\uff0c\u5e76\u63d0\u4ea4\u4f60\u7684 pull requests\u3002\u6211\u4eec\u4e5f\u6b22\u8fce\u4f60\u63d0\u51fa\u95ee\u9898\u6216\u63d0\u4f9b\u53cd\u9988\u3002\n\n## \u8bb8\u53ef\u8bc1\n\n\u8be5\u9879\u76ee\u91c7\u7528 [MIT \u8bb8\u53ef\u8bc1](./LICENSE)\u3002\n\n## \u5176\u4ed6\n\u672c\u9879\u76ee\u4e3b\u8981\u53c2\u8003[ai-commit](https://github.com/Sitoi/ai-commit)",
"bugtrack_url": null,
"license": "MIT",
"summary": "A CLI tool to generate commit messages using AI models",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/xiaojinwhu/commitor",
"Repository": "https://github.com/xiaojinwhu/commitor"
},
"split_keywords": [
"git",
" commit",
" ai",
" gpt",
" openai"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "682300214a6c3f0b0efee6ff33498a0efda4279d4d81906ea129770184970714",
"md5": "c2b29d35105508d6bd8c7d2c6ca9c46c",
"sha256": "818109b87236477f684f8892a781c304268dd29cf5da7290318930ef4f16abe6"
},
"downloads": -1,
"filename": "commitor-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c2b29d35105508d6bd8c7d2c6ca9c46c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 8414,
"upload_time": "2024-03-27T08:29:38",
"upload_time_iso_8601": "2024-03-27T08:29:38.152708Z",
"url": "https://files.pythonhosted.org/packages/68/23/00214a6c3f0b0efee6ff33498a0efda4279d4d81906ea129770184970714/commitor-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a2699686819540f3bec745f3234f18a69f779ac200f0330189bd0b82c77ff3c5",
"md5": "74af6b613000309fea7cce7c4f1df962",
"sha256": "42fc2c5a9048021d4f8431cc203c6e3736f930d92b13c1faaea6926db21a7c52"
},
"downloads": -1,
"filename": "commitor-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "74af6b613000309fea7cce7c4f1df962",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 7545,
"upload_time": "2024-03-27T08:29:39",
"upload_time_iso_8601": "2024-03-27T08:29:39.939617Z",
"url": "https://files.pythonhosted.org/packages/a2/69/9686819540f3bec745f3234f18a69f779ac200f0330189bd0b82c77ff3c5/commitor-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 08:29:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xiaojinwhu",
"github_project": "commitor",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "commitor"
}