Add your description here
Project description
Auto Git Commit Message
auto-git-msg 是一个基于 Google Gemini 构建的智能 Git 提交信息生成工具。它不仅仅是一个简单的生成器,更是一个能够理解项目上下文的智能代理(Agent)。
这个工具可以通过分析暂存区(staged)或工作区(unstaged)的代码变更,自动生成符合 Conventional Commits 规范的高质量 Git Commit Message。
✨ 功能特性
- 智能生成: 基于强大的 Gemini 模型分析代码
diff,生成准确、专业的提交信息。 - 遵循规范: 自动格式化为
type(scope): subject的 Conventional Commits 格式。 - 上下文感知: 能够像开发者一样
ls和cd,在生成消息前探索项目结构,提高 scope 的准确性。 - 灵活输入:
- 自动分析暂存区的代码变更。
- 可通过指令分析工作区(未暂存)的变更。
- 可以优化您手写的、不规范的 commit message。
- 智能过滤: 自动忽略
*.lock等版本锁定文件,聚焦核心代码变更。 - 风格参考: 能够获取上一次的 commit message,以保持提交风格的一致性。
- 代理支持: 自动检测并使用系统环境变量(
https_proxy,http_proxy)或配置文件中的代理。
🚀 安装
先决条件
- Python 3.9+
- Git
安装步骤
使用 pip 即可安装:
# 使用 pip
pip install auto-git-msg
⚙️ 配置
首次使用时,工具会提示您输入 Google Gemini API 密钥。输入后,密钥将被自动保存在您用户主目录下的 ~/.auto-git-msg.json 文件中,后续无需再次配置。
您也可以通过命令行参数手动配置:
- 指定密钥(自动保存)
auto-git-msg --api-key YOUR_API_KEY "Generate a commit message"
代理配置
如果您的网络环境需要代理才能访问 Google API,本工具会自动检测 https_proxy 或 http_proxy 环境变量。
您也可以通过命令显式设置或取消代理:
-
设置代理
auto-git-msg --set-proxy http://127.0.0.1:7890
此命令会将代理信息写入
~/.auto-git-msg.json配置文件中。 -
取消代理
auto-git-msg --unset-proxy
📖 使用方法
确保您的代码变更已经通过 git add 添加到暂存区。
基本用法
-
为暂存区的变更生成提交信息
auto-git-msg
-
提供额外指令或上下文 如果变更多而复杂,您可以给 AI 一些提示。
auto-git-msg "这些改动主要重构了后端的认证模块"
-
为未暂存的变更生成提交信息
auto-git-msg "为我所有未暂存的变更生成一个 commit message"
-
优化已有的提交信息 让 AI 帮你把一个简单的想法变成规范的 commit message。
auto-git-msg --message "fix: 修复登录bug"
高级用法
- 在指定项目目录运行
使用
-C或--chdir参数切换到目标目录。auto-git-msg -C ../another-project "为那个项目的改动生成 commit"
📄 许可证
本项目采用 MIT 许可证。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auto_git_msg-0.1.1.tar.gz.
File metadata
- Download URL: auto_git_msg-0.1.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87e063909d86240a9add519c8912ade9f3e1af450c1772076140c50564d88a8b
|
|
| MD5 |
3d89dcc097d5365bd22d6f0be829cbeb
|
|
| BLAKE2b-256 |
97c06de6822a6db7f343e5a9c1de772729b55b3c2d95db60fff085e43d504ae2
|
File details
Details for the file auto_git_msg-0.1.1-py3-none-any.whl.
File metadata
- Download URL: auto_git_msg-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a3a358c539699f90c1b27c9c18b5e2567fe0b2e61e9dc5e4f1372f8a2e2f465
|
|
| MD5 |
3945af8af8ae06635cd91e6d09a42984
|
|
| BLAKE2b-256 |
4db897b96ba29d36005bfd142780e2289a234894bd2fd979b839c0a7e06de53f
|