pull-request
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePull Request Creation
拉取请求(Pull Request)创建
Create a GitHub pull request for the current branch. Works in any Git repository with GitHub as the remote.
Pull requests are created at the user's discretion -- this skill is never triggered automatically after commits.
为当前分支创建GitHub拉取请求。适用于任何以GitHub作为远程仓库的Git项目。
拉取请求的创建由用户自主决定——该技能绝不会在提交代码后自动触发。
Workflow
工作流程
Step 1: Readiness Check
步骤1:就绪检查
Verify the branch is ready for a pull request.
- Check that the current branch has commits ahead of the base branch using .
git log <base>..HEAD - If there are no commits ahead, inform the user there is nothing to create a PR for and stop.
- If the current branch is not pushed to the remote, push it with tracking: .
git push -u origin <branch> - Check if a PR already exists for the current branch using . If one exists, display the existing PR URL and ask the user whether to update it or abort.
gh pr view
验证分支是否已准备好创建拉取请求。
- 使用检查当前分支是否有比基准分支新的提交。
git log <base>..HEAD - 如果没有新提交,告知用户没有内容可用于创建PR并终止流程。
- 如果当前分支尚未推送到远程仓库,使用跟踪模式推送:。
git push -u origin <branch> - 使用检查当前分支是否已存在对应的PR。如果已存在,显示现有PR的URL,并询问用户是要更新该PR还是终止操作。
gh pr view
Step 2: Draft PR Content
步骤2:生成PR草稿内容
Generate a title and body from the commit history.
- Display the commit log between the base branch and HEAD: .
git log --oneline <base>..HEAD - Display the full diff: .
git diff <base>...HEAD - Draft a PR title (under 72 characters) and body:
- Title: concise summary of the changes in imperative form
- Body: structured summary with sections as appropriate
- Follow repository conventions if visible from recent PRs
- Present the draft to the user. They may approve, edit, or rewrite it.
从提交历史生成标题和正文。
- 显示基准分支与HEAD之间的提交日志:。
git log --oneline <base>..HEAD - 显示完整的差异对比:。
git diff <base>...HEAD - 生成PR标题(不超过72个字符)和正文:
- 标题:以祈使句形式简洁概括变更内容
- 正文:根据需要分结构化的摘要
- 如果从近期PR中能看出仓库的规范,需遵循该规范
- 将草稿内容呈现给用户,用户可选择批准、编辑或重写。
Step 3: Create PR
步骤3:创建PR
- Create the pull request on confirmation:
bash
gh pr create --title "<title>" --body "$(cat <<'EOF' <body> EOF )" - Display the PR number and URL.
- 确认后创建拉取请求:
bash
gh pr create --title "<title>" --body "$(cat <<'EOF' <body> EOF )" - 显示PR编号和URL。
Error Handling
错误处理
If PR creation fails, display the error message returned by .
gh pr create如果PR创建失败,显示返回的错误信息。
gh pr createBefore Finishing
完成前检查
After creating the PR, review it from a reviewer's perspective:
- Understandable? Can a reviewer who has no context about the conversation understand what this PR does and why, from the title and body alone?
- Complete? Does the diff include all intended changes? Check for unstaged changes that may have been missed.
git status
创建PR后,从审核者的角度进行复查:
- 易懂性? 没有上下文的审核者能否仅通过标题和正文理解该PR的作用和原因?
- 完整性? 差异对比是否包含了所有预期的变更?检查是否有未暂存的遗漏变更。
git status
Constraints
约束条件
- Do not merge the PR -- creation only.
- Do not force-push or rebase without explicit user request.
- The base branch defaults to the repository's default branch unless the user specifies otherwise.
- 不得合并PR——仅负责创建操作。
- 未经用户明确请求,不得强制推送或变基。
- 基准分支默认为仓库的默认分支,除非用户另行指定。