conventional-pull-requests

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Conventional Pull Requests

规范式拉取请求(Conventional Pull Requests)

Goal

目标

Create pull requests with:
  • a Conventional Commits style title
  • a body that follows the repository PR template
  • concise, accurate change context derived from the actual diff
创建具备以下特点的拉取请求:
  • 符合Conventional Commits风格的标题
  • 遵循仓库PR模板的正文内容
  • 从实际代码差异中提炼出简洁、准确的变更背景

Workflow

工作流程

  1. Inspect branch and commit context.
    • Run
      git status --short
      ,
      git log --oneline --decorate -n 20
      , and identify the current branch.
    • Determine the default base branch with
      gh repo view --json defaultBranchRef -q '.defaultBranchRef.name'
      .
    • Review diff scope with
      git diff --name-status origin/<base>...HEAD
      .
  2. Confirm there is meaningful committed work for a PR.
    • If there are only uncommitted changes, ask whether to create commits first.
  3. Find and read the PR template before drafting.
    • Check
      .github/pull_request_template.md
      ,
      .github/PULL_REQUEST_TEMPLATE.md
      , and
      .github/PULL_REQUEST_TEMPLATE/*.md
      .
  4. Draft a conventional title.
    • Format:
      <type>[optional-scope]: <description>
    • Use standard types:
      feat
      ,
      fix
      ,
      docs
      ,
      refactor
      ,
      test
      ,
      chore
      ,
      build
      ,
      ci
      ,
      perf
      ,
      style
      ,
      revert
      .
    • Keep description imperative and specific.
  5. Draft the PR body from the template.
    • Fill all required sections with concrete details from the diff.
    • Include testing notes and risk notes when relevant.
    • Generate a comprehensive PR body with a summary, key changes, architecture benefits if necessary, technical details, and testing information.
  6. Push the branch if needed.
    • Run
      git push -u origin <branch>
      when the branch has no upstream or local commits are not yet pushed.
  7. Create the PR with GitHub CLI.
    • Use
      gh pr create --base <base> --head <branch> --title "<title>" --body-file <file>
      .
    • Use
      --draft
      only when explicitly requested.
  8. Return the PR URL and a short summary of title/body decisions.
  1. 检查分支和提交上下文。
    • 运行
      git status --short
      git log --oneline --decorate -n 20
      ,并确定当前分支。
    • 通过
      gh repo view --json defaultBranchRef -q '.defaultBranchRef.name'
      确定默认基准分支。
    • 通过
      git diff --name-status origin/<base>...HEAD
      查看代码差异范围。
  2. 确认存在可用于PR的有效提交工作。
    • 如果只有未提交的变更,询问是否先创建提交。
  3. 在草拟PR前查找并阅读PR模板。
    • 检查
      .github/pull_request_template.md
      .github/PULL_REQUEST_TEMPLATE.md
      .github/PULL_REQUEST_TEMPLATE/*.md
      文件。
  4. 草拟符合规范的标题。
    • 格式:
      <type>[可选范围]: <描述>
    • 使用标准类型:
      feat
      fix
      docs
      refactor
      test
      chore
      build
      ci
      perf
      style
      revert
    • 描述部分使用祈使语气且具体明确。
  5. 根据模板草拟PR正文。
    • 用代码差异中的具体细节填充所有必填部分。
    • 相关时包含测试说明和风险提示。
    • 生成包含摘要、关键变更、架构优势(如有必要)、技术细节和测试信息的完整PR正文。
  6. 必要时推送分支。
    • 当分支没有上游分支或本地提交尚未推送时,运行
      git push -u origin <branch>
  7. 使用GitHub CLI创建PR。
    • 使用命令
      gh pr create --base <base> --head <branch> --title "<title>" --body-file <file>
    • 仅在明确要求时使用
      --draft
      参数。
  8. 返回PR链接以及关于标题/正文决策的简短总结。

Rules

规则

  • Do not invent changes; use only facts from the branch diff and commits.
  • Ask one focused clarification when required template fields cannot be inferred.
  • Prefer a small, clear PR description over verbose narrative.
  • 不得虚构变更内容;仅使用分支差异和提交中的事实信息。
  • 当无法推断必填模板字段时,提出一个聚焦的澄清问题。
  • 优先选择简洁清晰的PR描述,而非冗长的叙述。