pr-create
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate 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.mdHelp
帮助
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 () must be available.
gh - 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 -vDetermine:
- 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:
- Check if the current branch was created from a release branch:
bX.Y.Zbashgit log --oneline --decorate --all | head -30 git merge-base --is-ancestor origin/latest HEAD && echo "descends from latest" - Default base: (the main branch).
latest - Release base: If the branch clearly descends from a branch (and not
bX.Y.Z), use that release branch as the base.latest - If ambiguous, ask the user which base branch to target.
Store the result as .
BASE_BRANCH确定PR对应的正确基准分支:
- 检查当前分支是否基于格式的发布分支创建:
bX.Y.Zbashgit log --oneline --decorate --all | head -30 git merge-base --is-ancestor origin/latest HEAD && echo "descends from latest" - 默认基准分支:(主分支)。
latest - 发布基准分支:如果分支明确继承自格式的分支(而非
bX.Y.Z),则使用该发布分支作为基准分支。latest - 如果存在歧义,询问用户需要指向的基准分支。
将结果存储为。
BASE_BRANCHSTEP 3: Ensure Topic Branch
步骤3:确保使用主题分支
If currently on or a branch, a new topic branch is required:
latestbX.Y.Z- Determine the branch name following git-conventions:
- If contains a JIRA ticket (e.g.,
${ARGUMENTS}): useAG-12345ag-12345/<descriptive-slug> - Otherwise: use (derive initials from
<initials>/<descriptive-slug>, or ask the user)git config user.name - Derive the slug from the change description or .
${ARGUMENTS}
- If
- Create and switch to the new branch:
bash
git checkout -b <branch-name>
If already on a topic branch (not or ), continue on the current branch.
latestbX.Y.Z如果当前处于或格式的分支上,则需要新建一个主题分支:
latestbX.Y.Z- 遵循Git规范确定分支名称:
- 如果中包含JIRA工单编号(例如
${ARGUMENTS}):使用AG-12345格式ag-12345/<描述性短名> - 否则:使用格式(从
<姓名缩写>/<描述性短名>中提取姓名缩写,或询问用户)git config user.name - 从变更描述或中提取描述性短名。
${ARGUMENTS}
- 如果
- 创建并切换到新分支:
bash
git checkout -b <branch-name>
如果当前已经在主题分支上(非或分支),则继续使用当前分支。
latestbX.Y.ZSTEP 4: Commit Changes (If Any)
步骤4:提交变更(如有)
If there are uncommitted changes:
- Review the changes:
bash
git diff git diff --staged git status - Stage relevant files (prefer specific files over ).
git add -A - Write a commit message following git-conventions:
- JIRA-linked: (uppercase JIRA number)
AG-XXXX <description> - No JIRA: (concise, imperative mood)
<description> - Under 72 characters.
- Never attribute agentic tooling.
- JIRA-linked:
- 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.
如果存在未提交的变更:
- 审查变更内容:
bash
git diff git diff --staged git status - 暂存相关文件(优先指定具体文件,而非使用)。
git add -A - 遵循Git规范编写提交信息:
- 关联JIRA的提交:(JIRA编号大写)
AG-XXXX <描述> - 无JIRA的提交:(简洁,使用祈使语气)
<描述> - 长度不超过72个字符。
- 禁止标注智能工具生成相关内容。
- 关联JIRA的提交:
- 提交变更:
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 :
ghbash
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: . No JIRA:
AG-XXXX <description>.<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"
使用创建PR:
ghbash
gh pr create --base <BASE_BRANCH> --title "<title>" --body "$(cat <<'EOF'
<body>
EOF
)"PR内容遵循Git规范:
- 标题:不超过70个字符。关联JIRA的PR:。无JIRA的PR:
AG-XXXX <描述>。<描述> - 正文:关联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}- A JIRA ticket number (e.g., ) - used for branch naming, commit prefix, and PR title.
AG-12345 - A description of the change - used for branch slug, commit message, and PR title.
- - override the base branch detection.
--base <branch>
Examples:
- - infer everything from current state and changes.
/pr-create - - JIRA-linked PR.
/pr-create AG-12345 Add tooltip delay support - - no-JIRA PR.
/pr-create Fix axis label overlap for long text - - target a specific release branch.
/pr-create --base b13.0.0
${ARGUMENTS}- JIRA工单编号(例如)——用于分支命名、提交信息前缀和PR标题。
AG-12345 - 变更描述——用于分支短名、提交信息和PR标题。
- ——覆盖基准分支自动检测逻辑。
--base <branch>
示例:
- ——根据当前状态和变更自动推断所有信息。
/pr-create - ——关联JIRA的PR。
/pr-create AG-12345 Add tooltip delay support - ——无JIRA关联的PR。
/pr-create Fix axis label overlap for long text - ——指向特定发布分支的PR。
/pr-create --base b13.0.0