# 创建拉取请求
按照 Sentry 的工程实践创建拉取请求。
**要求**:已认证并可用的 GitHub CLI (`gh`)。
## 流程
### 第一步:验证分支状态
bash
# 检查当前分支和状态
git status
git log main..HEAD --oneline
确保:
- 所有变更已提交
- 分支与远程仓库保持同步
- 如有必要,变更已基于 main 分支进行变基 (rebase)
### 第二步:分析变更
审查将包含在 PR 中的内容:
bash
# 查看 PR 中将包含的所有提交
git log main..HEAD
# 查看完整差异
git diff main...HEAD
在编写描述之前,了解所有变更的范围和目的。
### 第三步:编写 PR 描述
遵循此结构:
markdown
**不要包含:**
- “测试计划”部分
- 测试步骤的复选框列表
- 差异的冗余摘要
**请包含:**
- 关于“什么”和“为什么”的清晰解释
- 指向相关问题或工单的链接
- 代码中不明显的上下文
- 需要仔细审查的特定区域的说明
### 第四步:创建 PR
bash
gh pr create --title "(): " --body "$(cat <<'EOF'
EOF
)"
**标题格式**遵循提交约定:
- `feat(scope): Add new feature`
- `fix(scope): Fix the bug`
- `ref: Refactor something`
### 第五步:添加审查者 (如已知)
bash
# 请求特定人员审查
gh pr edit --add-reviewer username1,username2
# 或请求团队审查
gh pr edit --add-reviewer @getsentry/team-name
限制在 1-3 名审查者以保持清晰的所有权。
## PR 描述示例
### 功能 PR
markdown
Add Slack thread replies for alert notifications
When an alert is updated or resolved, we now post a reply to the original
Slack thread instead of creating a new message. This keeps related
notifications grouped and reduces channel noise.
Previously considered posting edits to the original message, but threading
better preserves the timeline of events and works when the original message
is older than Slack's edit window.
Refs SENTRY-1234
### Bug 修复 PR
markdown
Handle null response in user API endpoint
The user endpoint could return null for soft-deleted accounts, causing
dashboard crashes when accessing user properties. This adds a null check
and returns a proper 4
数据来源:claude-code-templates(MIT),中文翻译由 AI 生成。详见关于我们。