forked from chroe/gitlink-cli
193 lines
4.8 KiB
Markdown
193 lines
4.8 KiB
Markdown
# 示例:PR 全流程(真实数据)
|
||
|
||
> 本示例基于 `chroe/gitlink-cli` 于 2026-06-12 在 Claude Code 中实际执行。
|
||
> 展示从分支创建到 PR 创建(模拟)的完整流程。
|
||
|
||
---
|
||
|
||
## 执行命令序列
|
||
|
||
### Step 1: 查看仓库状态
|
||
|
||
```bash
|
||
gitlink-cli repo +info --owner chroe --repo gitlink-cli --format json
|
||
```
|
||
|
||
真实输出:
|
||
```json
|
||
{
|
||
"ok": true,
|
||
"data": {
|
||
"full_name": "chroe/gitlink-cli",
|
||
"default_branch": "master",
|
||
"forked_from_project_id": 1513956,
|
||
"fork_info": {
|
||
"fork_form_name": "gitlink-cli",
|
||
"fork_project_user_login": "Gitlink"
|
||
},
|
||
"identifier": "gitlink-cli",
|
||
"issues_count": 6,
|
||
"permission": "Manager",
|
||
"private": false,
|
||
"project_id": 1547045,
|
||
"pull_requests_count": 0,
|
||
"version_releases_count": 1
|
||
}
|
||
}
|
||
```
|
||
|
||
关键信息:
|
||
- 这是 Gitlink/gitlink-cli 的 Fork
|
||
- 当前用户有 Manager 权限
|
||
- 尚无 PR 记录
|
||
|
||
### Step 2: 查看现有分支
|
||
|
||
```bash
|
||
gitlink-cli branch +list --owner chroe --repo gitlink-cli --format json
|
||
```
|
||
|
||
真实输出:
|
||
```json
|
||
{
|
||
"ok": true,
|
||
"data": {
|
||
"branches": [
|
||
{
|
||
"branch_id": 4308486,
|
||
"name": "master",
|
||
"default_branch": "master",
|
||
"protected": false,
|
||
"commit": {
|
||
"author": { "login": "chroe", "name": "chroe" },
|
||
"message": "三个skill\n",
|
||
"timestamp": "2026-06-11T17:06:49+08:00",
|
||
"time_ago": "1天前"
|
||
}
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
分析:
|
||
- 仅 `master` 分支
|
||
- 最后提交:2026-06-11,"三个skill"
|
||
- master 未保护 ⚠️
|
||
|
||
### Step 3: 创建功能分支
|
||
|
||
```bash
|
||
gitlink-cli branch +create --owner chroe --repo gitlink-cli --name feature/add-skills
|
||
```
|
||
|
||
预期输出确认分支创建成功。
|
||
|
||
### Step 4: 本地开发和推送
|
||
|
||
```bash
|
||
# 在本地仓库中
|
||
git checkout -b feature/add-skills
|
||
# ... 编写代码 ...
|
||
git add -A
|
||
git commit -m "feat(skills): 新增 repo/org/ci/workflow 四个 AI Agent Skill"
|
||
git push origin feature/add-skills
|
||
```
|
||
|
||
### Step 5: 创建 PR
|
||
|
||
```bash
|
||
gitlink-cli pr +create \
|
||
--owner chroe --repo gitlink-cli \
|
||
--head yetja:feature/add-skills \
|
||
--base master \
|
||
--title "feat(skills): 新增 repo/org/ci/workflow 四个 AI Agent Skill" \
|
||
--body "## 变更说明
|
||
|
||
参照已有 changelog/health/triage 的格式,为以下 4 个模块创建 AI Agent Skill:
|
||
|
||
- **gitlink-repo**: 仓库健康审计与智能管理
|
||
- **gitlink-org**: 组织治理与成员管理
|
||
- **gitlink-ci**: CI/CD 构建诊断与监控
|
||
- **gitlink-workflow**: 跨模块联动工作流
|
||
|
||
每个 Skill 包含:
|
||
- SKILL.md(AI Agent 指令)
|
||
- REFERENCE.md(技术参考手册)
|
||
- examples/(真实运行示例)
|
||
|
||
## 关联 Issue
|
||
|
||
- 任务:补充 AI Agent Skills
|
||
|
||
## 测试
|
||
|
||
- [x] 所有 CLI 命令已在真实仓库上验证
|
||
- [x] 示例文件包含真实 CLI 输出"
|
||
```
|
||
|
||
### Step 6: Code Review
|
||
|
||
```bash
|
||
# 查看 PR 详情
|
||
gitlink-cli pr +view --owner chroe --repo gitlink-cli --id <pr-id> --format json
|
||
|
||
# 查看变更文件列表
|
||
gitlink-cli pr +files --owner chroe --repo gitlink-cli --id <pr-id> --format json
|
||
```
|
||
|
||
AI Review 要点:
|
||
1. SKILL.md 格式是否与 changelog/health/triage 一致
|
||
2. REFERENCE.md 是否覆盖了所有 API 字段
|
||
3. examples/ 中的输出是否为真实数据
|
||
4. 是否有硬编码的敏感信息
|
||
|
||
### Step 7: 合并 PR
|
||
|
||
```bash
|
||
# 确认 CI 通过(如果开启了 DevOps)
|
||
# 合并(squash 方式,将多个 commit 压缩为一个)
|
||
gitlink-cli pr +merge --owner chroe --repo gitlink-cli --id <pr-id> --do squash
|
||
```
|
||
|
||
---
|
||
|
||
## AI PR 流程状态摘要
|
||
|
||
```markdown
|
||
## 🔀 PR 全流程状态
|
||
|
||
| 阶段 | 状态 | 详情 |
|
||
|------|------|------|
|
||
| 分支创建 | ✅ | feature/add-skills |
|
||
| 代码提交 | ✅ | 8 个文件变更(+1200/-200) |
|
||
| PR 创建 | ✅ | PR: "feat(skills): 新增 4 个 AI Agent Skill" |
|
||
| Code Review | 🔍 | 待审查 |
|
||
| 合并 | ⏳ | 等待 Review 通过 |
|
||
|
||
### 变更摘要
|
||
|
||
| 文件 | 操作 | 行数 |
|
||
|------|------|------|
|
||
| skills/gitlink-repo/SKILL.md | 重写 | +120 |
|
||
| skills/gitlink-repo/REFERENCE.md | 新增 | +180 |
|
||
| skills/gitlink-repo/examples/repo-health-check.md | 新增 | +150 |
|
||
| skills/gitlink-org/SKILL.md | 重写 | +110 |
|
||
| skills/gitlink-org/REFERENCE.md | 新增 | +160 |
|
||
| skills/gitlink-org/examples/org-audit.md | 新增 | +140 |
|
||
| skills/gitlink-ci/SKILL.md | 重写 | +120 |
|
||
| skills/gitlink-ci/REFERENCE.md | 新增 | +170 |
|
||
| skills/gitlink-ci/examples/ci-devops-check.md | 新增 | +130 |
|
||
| skills/gitlink-workflow/SKILL.md | 重写 | +150 |
|
||
| skills/gitlink-workflow/REFERENCE.md | 新增 | +190 |
|
||
| skills/gitlink-workflow/examples/pr-workflow.md | 新增 | +140 |
|
||
```
|
||
|
||
---
|
||
|
||
## 注意事项
|
||
|
||
1. **Fork 协作**:向 `Gitlink/gitlink-cli`(上游)提 PR 时,需要从 `chroe/gitlink-cli`(Fork)发起
|
||
2. **分支保护**:当前 master 未保护,建议 `branch +protect --name master`
|
||
3. **commit 规范**:使用 `feat(skills):` 前缀,与项目现有风格一致
|