feat: 重构被审查分支的选择逻辑
push 审查 check_branches 现在只表示「要做 push 审查的分支」,不再兼作 PR 目标分支: - 勾选具体分支:这些分支的 push 会审查,通过后晋级到管理分支 - 新增「任意分支」(*):所有分支的 push 都审查 - 留空:只审 PR,不审 push PR 审查 始终覆盖「勾选的分支 + 管理分支」作为合并目标。 管理分支是最终目标,不需要出现在检查分支里也能被保护。 管理分支从候选中移除 分支选择器不再列出管理分支——它是终点,不需要再检查自己。 安全边界 「任意分支」只扩大审查范围,不会把任意分支自动合并进管理分支; 晋级仍要求分支被显式勾选(promotesToManaged)。 同时修正一处语义错误 早先 branchMatches 把空列表当成「审所有分支」,导致新建仓库在用户 还没选分支时就审查全部 push。现在空列表明确表示「只审 PR」。 测试:分支匹配矩阵重写,覆盖 push/PR/晋级/保护目标四类判定,共 20 项通过。
This commit is contained in:
+3
-3
@@ -17,7 +17,7 @@ import { OcrRunner } from "./lib/ocr.js";
|
||||
import { JobQueue } from "./lib/queue.js";
|
||||
import {
|
||||
ReviewEngine, SkipJob, branchMatches, parseRepoUrl, pullRequestMatches,
|
||||
PROMOTION_MARKER,
|
||||
promotesToManaged, ANY_BRANCH, PROMOTION_MARKER,
|
||||
} from "./lib/review.js";
|
||||
|
||||
const APP_DIR = resolve(fileURLToPath(new URL(".", import.meta.url)));
|
||||
@@ -296,10 +296,10 @@ async function handlePullRequest(payload, cfg) {
|
||||
if (String(pr.body || "").includes(PROMOTION_MARKER)) {
|
||||
return { queued: 0, reason: "self-created promotion pull request; already reviewed on push" };
|
||||
}
|
||||
if (!pullRequestMatches(pr.head?.ref, pr.base?.ref, repo.check_branches)) {
|
||||
if (!pullRequestMatches(pr.head?.ref, pr.base?.ref, repo.check_branches, repo.managed_branch)) {
|
||||
return {
|
||||
queued: 0,
|
||||
reason: `neither head ${pr.head?.ref} nor base ${pr.base?.ref} is in the checked branch list`,
|
||||
reason: `PR base ${pr.base?.ref} is neither the managed branch nor a checked branch`,
|
||||
};
|
||||
}
|
||||
const toSha = pr.head?.sha;
|
||||
|
||||
Reference in New Issue
Block a user