create-pull-request

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create a Pull Request (
/olpr
)

创建拉取请求(
/olpr

When the user runs
/olpr
, or asks to open a pull request in a repo with a
mitodl
remote, guide them through creating a PR using the org's standard pull request template.
当用户运行
/olpr
,或者要求在带有
mitodl
远程仓库的代码库中打开拉取请求时,引导其使用该组织的标准拉取请求模板创建PR。

Auto-detection

自动触发

This skill should activate automatically (without
/olpr
) when:
  • The user says "create a PR", "open a pull request", "submit a PR", etc., and
  • The current repo has a remote URL containing
    github.com/mitodl/
    (verify with
    git remote -v
    ).
满足以下条件时,该技能应自动激活(无需输入
/olpr
):
  • 用户提及“create a PR”“open a pull request”“submit a PR”等表述,并且
  • 当前代码库的远程URL包含
    github.com/mitodl/
    (可通过
    git remote -v
    验证)。

Step 1 — Inspect the branch and diff

步骤1 — 检查分支与差异

Before prompting the user, gather context automatically:
bash
undefined
在提示用户之前,自动收集上下文信息:
bash
undefined

Confirm current branch and its upstream

确认当前分支及其上游分支

git --no-pager branch --show-current git --no-pager log --oneline origin/HEAD..HEAD
git --no-pager branch --show-current git --no-pager log --oneline origin/HEAD..HEAD

Check for an existing open PR on this branch

检查该分支是否已有开放的PR

gh pr view --json url,title,state 2>/dev/null

- If an open PR already exists for the branch, share its URL and stop —
  do not create a duplicate.
- If there are no commits ahead of the base, warn the user before proceeding.
gh pr view --json url,title,state 2>/dev/null

- 如果该分支已有开放的PR,分享其URL并终止流程——不要创建重复PR。
- 如果当前分支相对于基准分支没有提交记录,在继续前向用户发出警告。

Step 2 — Determine the base branch

步骤2 — 确定基准分支

Default to the repo's default branch (usually
main
). Override if the user specifies a different target.
bash
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'
默认使用代码库的默认分支(通常为
main
)。如果用户指定了其他目标分支,则覆盖默认设置。
bash
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'

Step 3 — Gather PR metadata

步骤3 — 收集PR元数据

Collect or infer:
FieldHow to obtain
TitleAsk the user, or suggest one derived from the branch name / commit messages
Linked ticketsAsk the user for issue numbers (Closes #, Fixes #, or N/A)
DescriptionAsk what the PR does; summarise from commits if the user says "summarise"
ScreenshotsAsk if UI changes are present; skip section if not applicable
Testing notesAsk how the changes were tested and how a reviewer can validate
Additional contextAsk for reviewer notes, caveats, or checklist items; skip if none
Draft?Ask if this should be a draft PR (default: no)
收集或推导以下信息:
字段获取方式
标题询问用户,或根据分支名称/提交信息生成建议标题
关联工单询问用户工单编号(格式为Closes #、Fixes #或N/A)
描述询问用户PR的功能;如果用户要求“总结”,则根据提交信息生成总结
截图询问是否存在UI变更;若不适用则跳过该部分
测试说明询问变更的测试方式,以及审核者如何验证
额外上下文询问审核者备注、注意事项或检查项;若无则跳过
是否为草稿?询问是否应创建草稿PR(默认:否)

Step 4 — Populate the template

步骤4 — 填充模板

Fill in the standard PR template below with the gathered information. Strip HTML comments before passing to
gh pr create
.
markdown
undefined
使用收集到的信息填写下方的标准PR模板。在传递给
gh pr create
之前,移除HTML注释。
markdown
undefined

What are the relevant tickets?

关联的工单有哪些?

<!-- Closes #<n> | Fixes #<n> | N/A -->
<!-- Closes #<n> | Fixes #<n> | N/A -->

Description (What does it do?)

描述(功能是什么?)

<description>
<description>

Screenshots (if appropriate):

截图(如适用):

<screenshot checklist, or delete section if not applicable>
<截图检查项,若不适用则删除该部分>

How can this be tested?

如何测试?

<testing instructions>
<测试说明>

Additional Context

额外上下文

<reviewer notes, or delete section if not applicable>

Checklist section (uncomment and populate **only** if there are pre-merge steps):

```markdown
<审核者备注,若不适用则删除该部分>

检查项部分(**仅当存在合并前步骤时**才取消注释并填充):

```markdown

Checklist:

检查清单:

  • <step>
undefined
  • <步骤>
undefined

Step 5 — Create the PR

步骤5 — 创建PR

bash
gh pr create \
  --repo mitodl/<repo> \
  --base <base-branch> \
  --title "<title>" \
  --body "<filled-in body>" \
  [--draft]
Confirm the PR URL returned by
gh pr create
and share it with the user.

bash
gh pr create \
  --repo mitodl/<repo> \
  --base <base-branch> \
  --title "<title>" \
  --body "<filled-in body>" \
  [--draft]
确认
gh pr create
返回的PR URL并分享给用户。

Full PR template (reference)

完整PR模板(参考)

What are the relevant tickets?

关联的工单有哪些?

<!--- If it fixes an open issue, please link to the issue here. --> <!--- Closes # ---> <!--- Fixes # ---> <!--- N/A --->
<!--- 如果修复了一个开放的issue,请在此处链接该issue。 --> <!--- Closes # ---> <!--- Fixes # ---> <!--- N/A --->

Description (What does it do?)

描述(功能是什么?)

<!--- Describe your changes in detail -->
<!--- 详细描述你的变更 -->

Screenshots (if appropriate):

截图(如适用):

<!--- optional - delete if empty --->
  • Desktop screenshots
  • Mobile width screenshots
<!--- 可选 - 为空则删除 -->
  • 桌面端截图
  • 移动端宽度截图

How can this be tested?

如何测试?

<!--- Please describe in detail how your changes have been tested. Include details of your testing environment, any set-up required (e.g. data entry required for validation) and the tests you ran to see how your change affects other areas of the code, etc. Please also include instructions for how your reviewer can validate your changes. --->
<!--- 请详细描述你的变更已通过哪些方式测试。 包括测试环境的细节、所需的任何设置 (例如验证所需的数据录入),以及你运行的测试 以查看变更对代码其他区域的影响等。 请同时提供审核者验证你的变更的步骤说明。 --->

Additional Context

额外上下文

<!--- optional - delete if empty ---> <!--- Please add any reviewer questions, details worth noting, etc. that will help in assessing this change. ---> <!--- Uncomment and add steps to be completed before merging this PR if necessary
<!--- 可选 - 为空则删除 ---> <!--- 请添加任何有助于评估此变更的审核者问题、值得注意的细节等。 ---> <!--- 如有必要,请取消注释并添加合并此PR前需完成的步骤

Checklist:

检查清单:

  • e.g. Update secret values in Vault before merging --->

---
  • 例如:合并前在Vault中更新密钥值 --->

---

Tips

提示

  • Summarise from commits: if the user asks you to write the description, run
    git --no-pager log --oneline origin/HEAD..HEAD
    and synthesise a concise summary from the commit messages.
  • Strip comments: remove all
    <!-- ... -->
    blocks from the body before calling
    gh pr create
    to keep the PR clean.
  • Screenshots: only include the Screenshots section when the PR touches UI code. Ask the user to attach images after the PR is created if needed.
  • Checklist: only uncomment and use the Checklist section when there are explicit pre-merge steps (e.g. Vault secret updates, migration runs). Leave it out otherwise.
  • Draft PRs: suggest
    --draft
    if the branch is a work-in-progress or the user mentions it isn't ready for review.
  • 从提交信息总结:如果用户要求撰写描述,运行
    git --no-pager log --oneline origin/HEAD..HEAD
    并从提交信息中生成简洁的总结。
  • 移除注释:在调用
    gh pr create
    之前,移除正文中所有
    <!-- ... -->
    块,以保持PR内容整洁。
  • 截图:仅当PR涉及UI代码时才包含截图部分。若需要,可在PR创建后让用户附上图片。
  • 检查清单:仅当存在明确的合并前步骤(例如Vault密钥更新、迁移运行)时,才取消注释并使用检查清单部分。否则忽略该部分。
  • 草稿PR:如果分支仍在开发中,或者用户提及尚未准备好审核,建议使用
    --draft
    参数。