publish

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Publish

代码推送与拉取请求管理

You are assisting with pushing commits and managing pull requests. Follow these steps:
你将协助完成代码提交推送和拉取请求管理工作,请遵循以下步骤:

1. Initial State Assessment

1. 初始状态检查

  • Run
    git status
    to check current branch and sync status
  • Run
    git fetch origin
    to get latest remote updates
  • Determine push strategy based on branch state
  • 执行
    git status
    命令检查当前分支和同步状态
  • 执行
    git fetch origin
    获取远程仓库的最新更新
  • 根据分支状态确定推送策略

2. Push Strategy

2. 推送策略

If branch is ahead of remote (normal push):
bash
git push -u origin HEAD
If branch has diverged from remote (after rebase):
bash
git push --force-with-lease
如果分支领先于远程仓库(常规推送):
bash
git push -u origin HEAD
如果分支与远程仓库出现分歧(变基后):
bash
git push --force-with-lease

3. PR Management

3. 拉取请求(PR)管理

After pushing, check for existing PR:
bash
gh pr view
If PR exists:
  • Review the current PR description
  • Compare with the actual changes (
    git diff origin/main...HEAD
    )
  • Update description if it doesn't accurately reflect the changes:
    gh pr edit
If no PR exists:
  • Create a new PR following the conventions below
  • Ask user whether to create as draft or ready for review
推送完成后,检查是否存在现有拉取请求:
bash
gh pr view
如果PR已存在:
  • 查看当前PR的描述内容
  • 与实际变更内容进行对比(执行
    git diff origin/main...HEAD
  • 如果描述与实际变更不符,执行
    gh pr edit
    更新描述
如果不存在PR:
  • 按照以下规范创建新的PR
  • 询问用户是创建为草稿状态还是可审核状态

PR Description Conventions

拉取请求(PR)描述规范

Template Selection

模板选择

  1. Check for project template:
    bash
    find . -maxdepth 2 -iname "pull_request_template.md" -print -quit
  2. Select template based on result:
    • Project template exists: Read and use the project template
    • No project template: Read templates/pr-template.md and use it
IMPORTANT: Always read the selected template file before creating the PR description. Never create a PR description without first reading a template.
  1. 检查项目是否有模板:
    bash
    find . -maxdepth 2 -iname "pull_request_template.md" -print -quit
  2. 根据检查结果选择模板:
    • 存在项目模板:读取并使用该项目模板
    • 无项目模板:读取templates/pr-template.md并使用该模板
重要提示:在创建PR描述前,务必先阅读选中的模板文件。禁止未阅读模板就创建PR描述。

Title

标题

  • MUST match a commit message subject line exactly
  • If multiple commits, ask user which to use
  • 必须与某条提交信息的主题行完全一致
  • 如果存在多条提交信息,询问用户使用哪一条

Language

语言

  • Match template language if project template exists
  • Default: English
  • Japanese: Use polite form (敬語)
  • 如果存在项目模板,语言需与模板保持一致
  • 默认:英文
  • 日文:使用礼貌语(敬語)

Signature

签名

Always end with:
text
🤖 Generated with [Claude Code](https://claude.ai/code)
必须以以下内容结尾:
text
🤖 Generated with [Claude Code](https://claude.ai/code)

4. Final Output

4. 最终输出

  • Display the PR URL
  • Show the current commit history relative to main
  • 展示PR的URL地址
  • 展示当前分支相对于main分支的提交历史