pr-create

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create Pull Request

创建Pull Request

Commit current changes (if any), push the branch, and open a pull request.
Read and follow all conventions in
.rulesync/skills/git-conventions/SKILL.md
.
提交当前变更(如有),推送分支并发起pull request。
请阅读并遵循
.rulesync/skills/git-conventions/SKILL.md
中的所有规范。

Help

帮助

If the user provides a command option of
help
:
  • Explain how to use this command.
  • DO NOT proceed, exit the command immediately after these steps.
如果用户提供了
help
命令选项:
  • 解释该命令的使用方法。
  • 不要继续执行后续步骤,完成解释后立即退出命令。

Prerequisites

前置要求

  • Git CLI and GitHub CLI (
    gh
    ) must be available.
  • The user must be authenticated with
    gh
    (
    gh auth status
    ).
  • The repository must have a remote named
    origin
    .
  • 必须安装Git CLI和GitHub CLI(
    gh
    )。
  • 用户必须已通过
    gh
    完成身份验证(可通过
    gh auth status
    查看状态)。
  • 代码仓库必须存在名为
    origin
    的远程仓库。

Workflow

工作流程

STEP 1: Assess Current State

步骤1:评估当前状态

Gather all necessary context in parallel:
bash
git status
git log --oneline -10
git branch --show-current
git remote -v
Determine:
  • Current branch name (
    CURRENT_BRANCH
    ).
  • Whether there are uncommitted changes (staged, unstaged, or untracked).
  • Whether there are unpushed commits on this branch.
并行收集所有必要的上下文信息:
bash
git status
git log --oneline -10
git branch --show-current
git remote -v
确认以下信息:
  • 当前分支名称
    CURRENT_BRANCH
    )。
  • 是否存在未提交的变更(已暂存、未暂存或未跟踪的文件)。
  • 当前分支是否存在未推送的提交

STEP 2: Identify Base Branch

步骤2:识别基准分支

Determine the correct base branch for the PR:
  1. Check if the current branch was created from a
    bX.Y.Z
    release branch:
    bash
    git log --oneline --decorate --all | head -30
    git merge-base --is-ancestor origin/latest HEAD && echo "descends from latest"
  2. Default base:
    latest
    (the main branch).
  3. Release base: If the branch clearly descends from a
    bX.Y.Z
    branch (and not
    latest
    ), use that release branch as the base.
  4. If ambiguous, ask the user which base branch to target.
Store the result as
BASE_BRANCH
.
确定PR对应的正确基准分支:
  1. 检查当前分支是否基于
    bX.Y.Z
    格式的发布分支创建:
    bash
    git log --oneline --decorate --all | head -30
    git merge-base --is-ancestor origin/latest HEAD && echo "descends from latest"
  2. 默认基准分支
    latest
    (主分支)。
  3. 发布基准分支:如果分支明确继承自
    bX.Y.Z
    格式的分支(而非
    latest
    ),则使用该发布分支作为基准分支。
  4. 如果存在歧义,询问用户需要指向的基准分支。
将结果存储为
BASE_BRANCH

STEP 3: Ensure Topic Branch

步骤3:确保使用主题分支

If currently on
latest
or a
bX.Y.Z
branch, a new topic branch is required:
  1. Determine the branch name following git-conventions:
    • If
      ${ARGUMENTS}
      contains a JIRA ticket (e.g.,
      AG-12345
      ): use
      ag-12345/<descriptive-slug>
    • Otherwise: use
      <initials>/<descriptive-slug>
      (derive initials from
      git config user.name
      , or ask the user)
    • Derive the slug from the change description or
      ${ARGUMENTS}
      .
  2. Create and switch to the new branch:
    bash
    git checkout -b <branch-name>
If already on a topic branch (not
latest
or
bX.Y.Z
), continue on the current branch.
如果当前处于
latest
bX.Y.Z
格式的分支上,则需要新建一个主题分支:
  1. 遵循Git规范确定分支名称:
    • 如果
      ${ARGUMENTS}
      中包含JIRA工单编号(例如
      AG-12345
      ):使用
      ag-12345/<描述性短名>
      格式
    • 否则:使用
      <姓名缩写>/<描述性短名>
      格式(从
      git config user.name
      中提取姓名缩写,或询问用户)
    • 从变更描述或
      ${ARGUMENTS}
      中提取描述性短名。
  2. 创建并切换到新分支:
    bash
    git checkout -b <branch-name>
如果当前已经在主题分支上(非
latest
bX.Y.Z
分支),则继续使用当前分支。

STEP 4: Commit Changes (If Any)

步骤4:提交变更(如有)

If there are uncommitted changes:
  1. Review the changes:
    bash
    git diff
    git diff --staged
    git status
  2. Stage relevant files (prefer specific files over
    git add -A
    ).
  3. Write a commit message following git-conventions:
    • JIRA-linked:
      AG-XXXX <description>
      (uppercase JIRA number)
    • No JIRA:
      <description>
      (concise, imperative mood)
    • Under 72 characters.
    • Never attribute agentic tooling.
  4. Commit:
    bash
    git commit -m "$(cat <<'EOF'
    <commit message>
    EOF
    )"
If there are no uncommitted changes and no unpushed commits, inform the user there is nothing to submit and STOP.
如果存在未提交的变更:
  1. 审查变更内容:
    bash
    git diff
    git diff --staged
    git status
  2. 暂存相关文件(优先指定具体文件,而非使用
    git add -A
    )。
  3. 遵循Git规范编写提交信息:
    • 关联JIRA的提交:
      AG-XXXX <描述>
      (JIRA编号大写)
    • 无JIRA的提交:
      <描述>
      (简洁,使用祈使语气)
    • 长度不超过72个字符。
    • 禁止标注智能工具生成相关内容。
  4. 提交变更:
    bash
    git commit -m "$(cat <<'EOF'
    <commit message>
    EOF
    )"
如果没有未提交的变更,也没有未推送的提交,告知用户没有可提交的内容并终止流程

STEP 5: Push Branch

步骤5:推送分支

Push the branch to the remote, setting the upstream:
bash
git push -u origin <branch-name>
将分支推送到远程仓库,设置上游分支:
bash
git push -u origin <branch-name>

STEP 6: Create Pull Request

步骤6:创建Pull Request

Create the PR using
gh
:
bash
gh pr create --base <BASE_BRANCH> --title "<title>" --body "$(cat <<'EOF'
<body>
EOF
)"
Follow git-conventions for the PR:
  • Title: Under 70 characters. JIRA-linked:
    AG-XXXX <description>
    . No JIRA:
    <description>
    .
  • Body: JIRA-linked: include link(s) to the JIRA ticket(s). No JIRA: concise description of the change.
  • Keep descriptions concise - this is a public repo.
  • Never attribute agentic tooling.
  • If JIRA-linked include "Fix #AG-XXXX"
使用
gh
创建PR:
bash
gh pr create --base <BASE_BRANCH> --title "<title>" --body "$(cat <<'EOF'
<body>
EOF
)"
PR内容遵循Git规范:
  • 标题:不超过70个字符。关联JIRA的PR:
    AG-XXXX <描述>
    。无JIRA的PR:
    <描述>
  • 正文:关联JIRA的PR:包含指向JIRA工单的链接。无JIRA的PR:对变更的简洁描述。
  • 保持描述简洁——本仓库为公开仓库。
  • 禁止标注智能工具生成相关内容。
  • 如果关联JIRA,需添加
    Fix #AG-XXXX
    内容。

STEP 7: Report Result

步骤7:反馈结果

Output the PR URL and a brief summary:
PR created: <URL>
  Base: <BASE_BRANCH> ← Head: <branch-name>
  Title: <title>
输出PR链接和简要摘要:
PR created: <URL>
  Base: <BASE_BRANCH> ← Head: <branch-name>
  Title: <title>

Arguments

参数

${ARGUMENTS}
can optionally include:
  • A JIRA ticket number (e.g.,
    AG-12345
    ) - used for branch naming, commit prefix, and PR title.
  • A description of the change - used for branch slug, commit message, and PR title.
  • --base <branch>
    - override the base branch detection.
Examples:
  • /pr-create
    - infer everything from current state and changes.
  • /pr-create AG-12345 Add tooltip delay support
    - JIRA-linked PR.
  • /pr-create Fix axis label overlap for long text
    - no-JIRA PR.
  • /pr-create --base b13.0.0
    - target a specific release branch.
${ARGUMENTS}
可选择性包含:
  • JIRA工单编号(例如
    AG-12345
    )——用于分支命名、提交信息前缀和PR标题。
  • 变更描述——用于分支短名、提交信息和PR标题。
  • --base <branch>
    ——覆盖基准分支自动检测逻辑。
示例:
  • /pr-create
    ——根据当前状态和变更自动推断所有信息。
  • /pr-create AG-12345 Add tooltip delay support
    ——关联JIRA的PR。
  • /pr-create Fix axis label overlap for long text
    ——无JIRA关联的PR。
  • /pr-create --base b13.0.0
    ——指向特定发布分支的PR。