用途:在创建、打开或准备 PR 接受审查时使用该技能,适用于任何变更的 PR 创建、分支提交准备以及协助贡献者开 PR。
核心规则:每个 PR 必须关联一个已获批准的 issue(无例外);每个 PR 必须恰好有一个 type:* 标签;自动化检查通过后才可能合并;无 issue 关联的空 PR 会被 GitHub Actions 阻止。
工作流:1. 确认 issue 带有 status:approved 标签;2. 按 type/description 命名创建分支;3. 用约定式提交实现变更;4. 对修改的脚本运行 shellcheck;5. 用模板打开 PR;6. 添加恰好一个 type:* 标签;7. 等待自动化检查通过。
分支命名必须匹配正则 ^(feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)/[a-z0-9._-]+$,格式为 type/description,描述仅小写字母、数字、点、下划线、连字符,不含空格。例如 feat/user-login、fix/zsh-glob-error。
PR 正文需包含:关联 issue(Closes/Fixes/Resolves #N,不区分大小写,关联 issue 必须有 status:approved 标签)、恰好勾选一个 PR 类型并添加对应标签(bug→type:bug、新功能→type:feature、仅文档→type:docs、重构→type:refactor、维护/工具→type:chore、破坏性变更→type:breaking-change)、1-3 条摘要、变更表格、测试计划、贡献者清单。
自动化检查包括:PR 校验中的 Check Issue Reference、Check Issue Has status:approved、Check PR Has type:* Label,以及 CI 的 Shellcheck。
提交信息须符合约定式提交正则,type 为 build、chore、ci、docs、feat、fix、perf、refactor、revert、style、test 之一,(scope) 可选小写,! 表示破坏性变更。提交类型映射到 PR 标签:feat→type:feature、fix→type:bug、docs→type:docs、refactor→type:refactor、chore/style/test/build/ci→type:chore、perf→type:feature、revert→type:bug、feat!/fix!→type:breaking-change。
命令示例:git checkout -b feat/my-feature main;shellcheck scripts/*.sh;git push -u origin feat/my-feature;gh pr create --title "feat(scope): description" --body "Closes #N";gh pr edit <pr-number> --add-label "type:feature"。
限制:需遵守上述强制规则,否则 PR 会被自动化阻止;不支持无 issue 关联的 PR。