SuperAPI AI 工具集

git-workflow

办公与效率

查看项目

更新于 10-15 22:13

技能介绍

用途:为仓库内所有涉及代码变更的任务提供统一 Git 流程,强制先检查分支再动手。

主要能力:分支检查与决策(在 main 上禁止直接改动,需先建分支;处于其他功能分支时询问用户);分支命名规范 {type}/{brief-description}-{issue-number},类型含 feature、fix、refactor、docs、ci、chore;一个 issue 只建一个分支,分支短生命周期、合并后删除;提交遵循 Conventional Commits,格式 {type}({scope}): {brief description},支持 feat、fix、docs、refactor、test、ci、chore、build、perf、style、revert,破坏性变更在类型后加 !,scope 可选(如 btc、bch、eth、xrp、db、api、cli、pr),由 lefthook commit-msg 钩子校验;提交前必须自检,按文件类型运行验证命令,如 Go 用 make go-lint && make tidy && make check-build && make go-test,Shell 用 make shfmt,Makefile 用 make mk-lint,SQL/HCL 用 make atlas-fmt && make atlas-lint;创建 PR 前必须先询问用户,多阶段任务需全部提交完成后再问。

使用方式:先执行 git branch --show-current 判断分支;在 main 上时执行 git fetch origin、git reset --hard origin/main 后 git checkout -b 新分支;建分支前用 git branch -a | grep "{issue-number}" 与 gh pr list --search "{issue-number}" 检查是否已有分支或 PR;提交后 git push -u origin {branch-name},经用户确认后用 gh pr create 创建 PR。

限制:禁止 git push --force、本地 git merge、在共享分支上 rebase 以及直接向 main 提交;未通过验证与自检不得提交;PR 创建需用户确认。