prepare-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prepare commit

准备提交

Checklist before a commit. Proceed to commit if explicitly asked, else stop when the checklist is done and wait.
提交前的检查清单。 如果明确要求提交,则继续提交;否则完成检查清单后停止并等待。

Workflow

工作流

Run in this order.
按以下顺序执行。

1. Originating artifacts

1. 原始依据

Re-read the ticket, task, or any other artifacts that were the starting point for this conversation, and the code diff.
  • Is everything in the ticket addressed?
  • Summarise the ticket and what changes have been made.
  • Note whether this change completes the ticket.
Where we have made decisions that contradict the ticket, keep the original brief and append a note saying what changed and why.
If there is no written starting point, say so and continue.
重新阅读工单、任务或作为本次对话起点的任何其他材料,以及代码 diff。
  • 工单中的所有事项是否都已处理?
  • 总结工单内容以及已完成的更改。
  • 说明此更改是否完成了工单。
如果我们做出的决定与工单相矛盾,请保留原始需求,并附上一条说明,指出更改了什么以及为什么。
如果没有书面形式的起点,请说明并继续。

2. Tests and lint

2. 测试和 lint

Prefer the project's documented lint and test entrypoints. Run lint, then tests. Fail-stop on either — do not present the work as ready to commit if either fails. If asked to commit and a check fails, don't commit; report.
Don't run a full production build unless the project documents that as the check to use.
优先使用项目文档中规定的 lint 和测试入口。先运行 lint,再运行测试。 任一检查失败都要立即停止;如果 lint 或测试失败,不要将工作呈现为已准备好提交。 如果要求提交但某项检查失败,不要提交;请进行报告。
除非项目文档将完整的 production build 指定为应使用的检查项,否则不要运行它。

3. Commit (only if asked)

3. 提交(仅在明确要求时)

  • Stage only the files that belong to this change. If the working tree has unrelated changes, stop and ask before committing; don't sweep them in.
  • Follow the project's commit and branch conventions.
  • Write a message saying what changed and why, and reference the ticket, if there is one.
  • Don't bypass hooks (
    --no-verify
    ). If a hook fails or changes files, stop and report.
  • Afterwards, check
    git status
    , and report the branch status and anything left uncommitted.
  • If you committed on
    main
    itself and the change completes the ticket, close the ticket. Otherwise leave it open.
  • 仅暂存属于本次更改的文件。 如果 working tree 中有无关的更改,提交前停止并询问;不要将其一并纳入。
  • 遵循项目的提交和分支约定。
  • 编写提交信息,说明更改了什么以及为什么;如果有工单,请引用该工单。
  • 不要绕过 hooks(
    --no-verify
    )。如果 hook 失败或修改了文件,请停止并报告。
  • 之后检查
    git status
    ,并报告分支状态以及任何未提交的内容。
  • 如果直接在
    main
    上提交,且此更改完成了工单,请关闭工单; 否则保持工单打开。

Hard rules

硬性规则

  • Do not amend, rewrite history, or push unless explicitly asked.
  • 除非明确要求,否则不要 amend、重写历史或 push。