mcpField
G
Git Commit Format

Git Commit Format

github.com/openshift开发54877 次安装今天更新
代码仓库

关于 Git Commit Format

用于规范 HyperShift 提交信息的 Conventional Commits 技能,涵盖消息结构、署名页脚、破坏性变更标记及 gitlint 验证。

主要功能

  1. 01Conventional Commits 结构
  2. 02提交类型与范围说明
  3. 03破坏性变更标记
  4. 04Signed-off-by 与 Assisted-by 页脚
  5. 05gitlint 验证规则

适用场景

  1. 01编写 HyperShift 功能或修复提交
  2. 02为 AI 辅助生成的信息添加署名
  3. 03检查标题、正文行和页脚

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/openshift/hypershift --skill git-commit-format

安装后在 Claude Code 中输入/git-commit-format确认已加载。

详细介绍

Git 提交消息格式规则

HyperShift 项目中的所有 Git 提交都应采用 Conventional Commits 格式。

提交消息格式

<type>(<scope>): <description>

[optional body]

[footers]

提交类型

  • feat:新功能
  • fix:修复错误
  • docs:文档变更
  • style:代码风格变更(格式等)
  • refactor:代码重构(不改变功能)
  • test:添加或更新测试
  • chore:维护任务
  • build:构建系统或依赖项变更
  • ci:CI/CD 变更
  • perf:性能改进
  • revert:撤销先前的提交

破坏性变更

使用 ! 提醒
feat!: send email when product shipped
使用 BREAKING CHANGE 页脚
feat: allow config to extend other configs

BREAKING CHANGE: `extends` key now used for extending config files
同时使用 ! 和 BREAKING CHANGE
chore!: drop support for Node 6

BREAKING CHANGE: use JavaScript features not available in Node 6.

必需的页脚

Signed-off-by 页脚

始终包含 Signed-off-by 页脚,并填写姓名和电子邮箱。

按以下优先级获取凭据:

  1. 环境变量:$GIT_AUTHOR_NAME 和 $GIT_AUTHOR_EMAIL
  2. Git 配置:git config user.name 和 git config user.email
  3. 如果两者都未配置,请向用户询问相关信息
Assisted-by 页脚

如果 AI 助手帮助创建或生成提交消息,请包含 Assisted-by: LLM 页脚。对于由人工撰写的提交消息,不要包含此页脚。

Assisted-by: LLM

Gitlint 验证规则

  • 运行 make run-gitlint 验证提交消息
  • 标题行:最多 120 个字符
  • 正文行:每行最多 140 个字符
  • 使用 Conventional Commits 格式
  • 包含必需的页脚(Signed-off-by)
  • 不要在行尾添加空格

示例

简单提交
docs: correct spelling of CHANGELOG

Signed-off-by: Bryan Cox <[email protected]>
Assisted-by: LLM
带作用域
feat(azure): add workload identity support

Signed-off-by: Bryan Cox <[email protected]>
Assisted-by: LLM
多段正文并带页脚
fix: prevent racing of requests

Introduce request ID and reference to latest request. Dismiss
incoming responses other than from latest request.

Remove timeouts which were used to mitigate racing but are
obsolete now.

Reviewed-by: Jane Doe
Refs: #123
Signed-off-by: Bryan Cox <[email protected]>
Assisted-by: LLM
Conventional Commits 示例

带有描述和破坏性变更页脚的提交消息:

feat: allow provided config object to extend other configs

Signed-off-by: Bryan Cox <[email protected]>
BREAKING CHANGE: `extends` key in config file is now used for extending other config files

使用 ! 提醒存在破坏性变更的提交消息:

feat!: send an email to the customer when a product is shipped

Signed-off-by: Bryan Cox <[email protected]>

带有作用域,并使用 ! 提醒存在破坏性变更的提交消息:

feat(api)!: send an email to the customer when a product is shipped

Signed-off-by: Bryan Cox <[email protected]>

同时使用 ! 和 BREAKING CHANGE 页脚的提交消息:

chore!: drop support for Node 6

Signed-off-by: Bryan Cox <[email protected]>
BREAKING CHANGE: use JavaScript features not available in Node 6.

没有正文的提交消息:

docs: correct spelling of CHANGELOG

Signed-off-by: Bryan Cox <[email protected]>

带有作用域的提交消息:

feat(lang): add Polish language

Signed-off-by: Bryan Cox <[email protected]>

带有多段正文和多个页脚的提交消息:

fix: prevent racing of requests

Introduce a request ID and a reference to the latest request. Dismiss
incoming responses other than from the latest request.

Remove timeouts which were used to mitigate the racing issue but are
obsolete now.

Reviewed-by: Z
Refs: #123
Signed-off-by: Bryan Cox <[email protected]>

快速检查清单

创建提交时:

  • 使用 Conventional Commits 格式:<type>(<scope>): <description>
  • 使用祈使语气撰写主题,并在适当时说明“原因”和“方式”
  • 标题少于 120 个字符
  • 正文每行少于 140 个字符
  • 包含 Signed-off-by 页脚
  • 如果 AI 助手帮助创建或生成提交消息,请包含 Assisted-by: LLM;如果由人工撰写,则省略
  • 使用 make run-gitlint 验证
  • 对于破坏性变更,使用 ! 或 BREAKING CHANGE

参考

Conventional Commits 规范:https://www.conventionalcommits.org/en/v1.0.0/#specification

评论

支持 Markdown