feat: 打通 推送→审查→晋级→关闭 Issue 的完整闭环
直接推送也能晋级 往受保护分支直接推代码(没有 PR)时,审查通过后自动开一个 <分支> → <管理分支> 的 PR 并合并它,而不是放弃自动合并。 已存在同类 open PR 时复用它,不重复创建。 晋级 PR 不再被重复审查 自动创建的 PR 带 PROMOTION_MARKER,其 pull_request 事件直接跳过。 同一批提交在 push 时已经审过,重复审会在合并完成后凭空造出 Issue (此前确实产生了这样一个幽灵 Issue)。 合并即关闭该仓库全部审查 Issue 两条触发路径: - 服务自己完成合并后立即关闭 - 人在 Gitea 手动合并时,pull_request closed + merged=true 事件触发关闭 手动合并是「代码已落地」最可靠的信号,不再依赖 push 侧的 merge 提交探测。 晋级使用 merge 而非 squash squash 会把晋级提交重写成全新提交,两个长期分支每晋级一次就多分叉 一点,最终必然冲突(已在 offerpai_h5 上复现 add/add 冲突)。 merge 保留共同祖先,下次晋级只携带新提交。 合并可等待性 Gitea 异步计算 mergeable,原先只轮询 5 秒就放弃。改为指数退避约 30 秒, 并区分「尚未算出」(继续等)与「确实冲突」(放弃)。失败时往 PR 留评论 说明原因,不再只写服务日志。 验证(真实 webhook): 推送 test → 审查通过 → 自动开 PR #9 (test→prd) → merge 合并 → pull_request merged 事件 → 关闭 0 个待处理 Issue prd 顶端前进为合并提交,test/prd 保持一致,无幽灵 Issue 产生
This commit is contained in:
@@ -232,6 +232,27 @@ export class GiteaClient {
|
||||
return this.get(`/api/v1/repos/${owner}/${repo}/pulls/${index}`);
|
||||
}
|
||||
|
||||
/** Open a pull request. */
|
||||
async createPullRequest(owner, repo, { title, head, base, body = "" }) {
|
||||
return this.post(`/api/v1/repos/${owner}/${repo}/pulls`, { title, head, base, body });
|
||||
}
|
||||
|
||||
/** Close a pull request without merging it. */
|
||||
async closePullRequest(owner, repo, index) {
|
||||
return this.patch(`/api/v1/repos/${owner}/${repo}/pulls/${index}`, { state: "closed" });
|
||||
}
|
||||
|
||||
/** Compare two refs; returns the file list, or null when they are identical. */
|
||||
async compareRefs(owner, repo, base, head) {
|
||||
try {
|
||||
return await this.get(`/api/v1/repos/${owner}/${repo}/compare/${base}...${head}`);
|
||||
} catch (err) {
|
||||
// Gitea answers 404 when the two refs point at the same commit.
|
||||
if (err.status === 404) return null;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async listPullRequests(owner, repo, query = {}) {
|
||||
return this.get(`/api/v1/repos/${owner}/${repo}/pulls`, { query });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user