SuperAPI AI 工具集

git-convention

编程与开发

查看项目

更新于 10-15 21:35

技能介绍

用途:按 Angular 提交规范撰写 git commit message,使提交信息可被机器读取,支持自动生成 changelog 与语义化版本控制(fix→PATCH、feat→MINOR、BREAKING CHANGE→MAJOR)。

格式:<type>[optional scope][!]: <subject>,其后可接可选 body 与 footer。在 type/scope 后加 ! 可标记破坏性变更,如 feat!: 或 feat(api)!:。

类型:feat(新功能)、fix(修复)、docs(文档)、style(格式/空白,不改逻辑)、refactor(既不修 bug 也不加功能的代码改动)、perf(性能优化)、test(测试)、build(构建系统或依赖)、ci(CI 配置)、chore(其他不改 src 或 test 的改动)、revert(回滚)。

scope:标识改动区域(模块、包、组件或功能名),小写且简短,如 auth、api、ui、user、core、payment、config。

subject 规则:祈使句现在时(用 add 而非 added/adds);首字母小写、结尾不加句号;不超过 72 字符。

body:说明改了什么与为什么,而非怎么实现;与 subject 之间空一行;多项改动可用项目符号。

footer:采用 git trailer 格式(Token: value 或 Token #value),常见如 Closes #123、BREAKING CHANGE: 描述、Refs: #456、Reviewed-by: Name。

最佳实践:全程使用祈使语气;subject 控制在 72 字符内;body 解释 what 与 why;footer 引用 issue;每次提交只做一项逻辑改动。避免过去时、首字母大写或句号结尾、一次提交混用多种类型、含糊的 subject(如 update stuff)、在信息里解释代码如何工作,以及添加 Co-Authored-By 或 AI 署名行。

工具:可用提交校验工具(常通过 husky、pre-commit、lefthook 作为 git hook)拒绝不合规提交;用 changelog 生成工具自动产出分类的 CHANGELOG.md(feat→Features、fix→Bug Fixes、BREAKING CHANGE→Breaking Changes)。各生态常见选择:JS/TS 用 commitlint + conventional-changelog;Python 用 commitizen;Flutter/Dart 用 changelog_cli + conventional_commit;Android 用 jreleaser + conventional-commit-gradle-plugin;Go 用 goreleaser + git-chglog;Rust 用 cog(cocogitto);Ruby 用 commitizen-rb;Java/Kotlin 用 jreleaser + conventional-commit-gradle-plugin;.NET/C# 用 GitVersion + MinVer;PHP 用 conventional-commits-php。

限制:资料未提供该技能的具体安装命令、平台支持范围、收费与价格信息,暂未提供。