config(git): 引入develop长期开发分支模型和git工作流自动化
This commit is contained in:
@@ -520,6 +520,84 @@ cmd.pipeline = {
|
||||
},
|
||||
};
|
||||
|
||||
// ──────── pr ────────
|
||||
|
||||
cmd.pr = {
|
||||
async list(api, opts) {
|
||||
const params = {};
|
||||
if (opts.options.state) params.state = opts.options.state;
|
||||
if (opts.options.base) params.base = opts.options.base;
|
||||
if (opts.options.head) params.head = opts.options.head;
|
||||
|
||||
const prs = await api.listPullRequests(params);
|
||||
out(prs);
|
||||
if (!opts.options.json) {
|
||||
outText(`\n🔀 Pull Requests (${prs.length || 0})\n`);
|
||||
if (!prs || !prs.length) { outText(' (无)'); return; }
|
||||
table(
|
||||
['#', '标题', '状态', 'Base', 'Head', '合并'],
|
||||
prs.map(p => [
|
||||
p.number,
|
||||
truncate(p.title, 35),
|
||||
p.state,
|
||||
p.base?.ref || '—',
|
||||
p.head?.ref || '—',
|
||||
p.merged ? '✅' : '—',
|
||||
])
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
async get(api, opts) {
|
||||
const num = opts.rest[0];
|
||||
if (!num) { fail('用法: pr get <number>'); return; }
|
||||
const pr = await api.getPullRequest(num);
|
||||
out(pr);
|
||||
if (!opts.options.json) {
|
||||
outText(`\n🔀 PR #${pr.number}: ${pr.title}`);
|
||||
outText(` 状态: ${pr.state}`);
|
||||
outText(` ${pr.base?.ref} ← ${pr.head?.ref}`);
|
||||
outText(` 合并: ${pr.merged ? '✅ 已合并' : '❌ 未合并'}`);
|
||||
if (pr.body) {
|
||||
outText(`\n--- Body ---\n${pr.body.slice(0, 500)}${pr.body.length > 500 ? '…' : ''}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async create(api, opts) {
|
||||
const base = opts.options.base || 'main';
|
||||
const head = opts.options.head;
|
||||
const title = opts.options.title;
|
||||
const body = opts.options.body || '';
|
||||
|
||||
if (!head || !title) {
|
||||
fail('用法: pr create --head <分支> --title "标题" [--base main] [--body "描述"]');
|
||||
return;
|
||||
}
|
||||
|
||||
const pr = await api.createPullRequest({ base, head, title, body });
|
||||
out(pr);
|
||||
if (!opts.options.json) {
|
||||
ok(`PR #${pr.number} 已创建: ${pr.title}`);
|
||||
outText(` ${pr.html_url}`);
|
||||
}
|
||||
},
|
||||
|
||||
async merge(api, opts) {
|
||||
const num = opts.rest[0];
|
||||
if (!num) { fail('用法: pr merge <number> [--style merge|squash|rebase]'); return; }
|
||||
const style = opts.options.style || 'merge';
|
||||
|
||||
const pr = await api.getPullRequest(num);
|
||||
if (pr.merged) { fail(`PR #${num} 已合并,无需重复操作`); return; }
|
||||
if (pr.mergeable === false) { fail(`PR #${num} 存在冲突,无法自动合并。请先解决冲突。`); return; }
|
||||
|
||||
const result = await api.mergePullRequest(num, { style });
|
||||
out(result);
|
||||
if (!opts.options.json) ok(`PR #${num} 已合并 (${style})`);
|
||||
},
|
||||
};
|
||||
|
||||
// ──────── test ────────
|
||||
|
||||
cmd.test = {
|
||||
@@ -682,6 +760,11 @@ Gitea CLI — 项目管理工具
|
||||
pipeline status 查看当前流水线进度
|
||||
pipeline update <#> 更新 Pipeline 字段 --field <阶段|当前迭代> --value <值>
|
||||
|
||||
pr list 列出 Pull Requests [--state open|closed|all] [--base <分支>] [--head <分支>]
|
||||
pr get <#> 查看 PR 详情
|
||||
pr create 创建 PR --head <分支> --title "标题" [--base main] [--body "描述"]
|
||||
pr merge <#> 合并 PR [--style merge|squash|rebase]
|
||||
|
||||
test 验证所有 API 接口
|
||||
|
||||
角色自动映射:
|
||||
|
||||
Reference in New Issue
Block a user