push
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePush Skill
Push Skill
Atomic test-commit-push workflow. Catches failures before they reach the remote.
原子化的 test-commit-push 工作流,在问题到达远程仓库前捕获故障。
Steps
步骤
Step 1: Detect Project Type
步骤1:检测项目类型
Determine which test suites apply:
- Go: Check for (or
go.mod). If found, Go tests apply.cli/go.mod - Python: Check for ,
requirements.txt, orpyproject.toml. If found, Python tests apply.setup.py - Shell: Check for modified files. If found, shellcheck applies (if installed).
.sh
确定适用的测试套件:
- Go: 检查是否存在(或
go.mod),如果存在则适用Go测试。cli/go.mod - Python: 检查是否存在、
requirements.txt或pyproject.toml,如果存在则适用Python测试。setup.py - Shell: 检查是否有修改过的文件,如果存在则适用shellcheck检查(若已安装)。
.sh
Step 2: Run Tests
步骤2:运行测试
Run ALL applicable test suites. Do NOT skip any.
Go projects:
bash
cd cli && go vet ./...
cd cli && go test ./... -count=1 -shortPython projects:
bash
python -m pytest --tb=short -qShell scripts (if shellcheck available):
bash
shellcheck <modified .sh files>If ANY test fails: STOP. Fix the failures before continuing. Do not commit broken code.
运行所有适用的测试套件,不得跳过任何一项。
Go项目:
bash
cd cli && go vet ./...
cd cli && go test ./... -count=1 -shortPython项目:
bash
python -m pytest --tb=short -qShell脚本(若可用shellcheck):
bash
shellcheck <modified .sh files>如果有任何测试失败:立即停止。 修复问题后再继续,不要提交存在问题的代码。
Step 3: Stage Changes
步骤3:暂存变更
bash
git add <specific files>Stage only the files relevant to the current work. Do NOT use unless the user explicitly requests it. Review untracked files and skip anything that looks like secrets, temp files, or build artifacts.
git add -Abash
git add <specific files>仅暂存与当前工作相关的文件。除非用户明确要求,否则不要使用。检查未追踪的文件,跳过所有看起来是密钥、临时文件或构建产物的内容。
git add -AStep 4: Write Commit Message
步骤4:编写提交信息
Write a conventional commit message based on the diff:
- Use conventional commit format:
type(scope): description - Types: ,
feat,fix,refactor,docs,test,chore,styleperf - Keep subject line under 72 characters
- Focus on WHY, not WHAT
基于diff编写约定式提交信息:
- 使用约定式提交格式:
type(scope): description - 类型包括:、
feat、fix、refactor、docs、test、chore、styleperf - 标题行长度不超过72个字符
- 重点说明改动原因,而非改动内容
Step 5: Commit
步骤5:提交
bash
git commit -m "<message>"bash
git commit -m "<message>"Step 6: Sync with Remote
步骤6:与远程仓库同步
bash
git pull --rebase origin $(git branch --show-current)If rebase conflicts occur: resolve them, re-run tests, then continue.
bash
git pull --rebase origin $(git branch --show-current)如果出现变基冲突:先解决冲突,重新运行测试,再继续操作。
Step 7: Push
步骤7:推送
bash
git push origin $(git branch --show-current)bash
git push origin $(git branch --show-current)Step 8: Report
步骤8:报告
Output a summary:
- Files changed count
- Tests passed (with suite names)
- Commit hash
- Branch pushed to
输出如下总结信息:
- 改动文件数量
- 测试通过情况(包含套件名称)
- 提交哈希值
- 推送的目标分支
Guardrails
防护规则
- NEVER push to or
mainwithout explicit user confirmationmaster - NEVER stage files matching: ,
.env*,*credentials*,*secret*,*.key*.pem - If tests were not run (no test suite found), WARN the user before committing
- If fails, do NOT force push — ask the user
git pull --rebase
- 未经用户明确确认,绝不允许推送到或
main分支master - 绝不暂存匹配以下规则的文件:、
.env*、*credentials*、*secret*、*.key*.pem - 如果未运行测试(未找到测试套件),提交前需要向用户发出警告
- 如果执行失败,不要强制推送 — 请询问用户后再操作
git pull --rebase