fix: 补齐NapCat上游审计干合并探测
This commit is contained in:
parent
4b18c1bec8
commit
1f60506c89
@ -129,8 +129,10 @@ export async function runSelfTest(): Promise<void> {
|
|||||||
const dryRunAuditCommandText = dryRunAuditCommands.join("\n");
|
const dryRunAuditCommandText = dryRunAuditCommands.join("\n");
|
||||||
for (const expected of [
|
for (const expected of [
|
||||||
"git status --short --branch",
|
"git status --short --branch",
|
||||||
"git fetch --dry-run",
|
"git fetch upstream --tags --prune",
|
||||||
|
"git fetch origin --prune",
|
||||||
"git diff --name-only",
|
"git diff --name-only",
|
||||||
|
"git merge-tree",
|
||||||
]) {
|
]) {
|
||||||
if (!dryRunAuditCommandText.includes(expected)) {
|
if (!dryRunAuditCommandText.includes(expected)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -139,15 +141,15 @@ export async function runSelfTest(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const forbidden of [
|
for (const forbidden of [
|
||||||
"git merge",
|
{ label: "git merge", regex: /(^|\n)\s*git\s+merge(?:\s|$)/ },
|
||||||
"git push",
|
{ label: "git push", regex: /(^|\n)\s*git\s+push(?:\s|$)/ },
|
||||||
"docker build",
|
{ label: "docker build", regex: /(^|\n)\s*docker\s+build(?:\s|$)/ },
|
||||||
"kubectl",
|
{ label: "kubectl", regex: /(^|\n)\s*kubectl(?:\s|$)/ },
|
||||||
"deploy",
|
{ label: "deploy", regex: /(^|\n)\s*deploy(?:\s|$)/ },
|
||||||
]) {
|
]) {
|
||||||
if (dryRunAuditCommandText.includes(forbidden)) {
|
if (forbidden.regex.test(dryRunAuditCommandText)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`NapCat upstream audit dry-run command is not read-only: ${forbidden}`,
|
`NapCat upstream audit dry-run command is not read-only: ${forbidden.label}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -254,8 +254,13 @@ export function buildNapcatUpstreamAudit(
|
|||||||
readOnly: true,
|
readOnly: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'git fetch --dry-run upstream --tags',
|
command: 'git fetch upstream --tags --prune',
|
||||||
description: 'Check whether upstream release refs are reachable without updating refs.',
|
description: 'Refresh upstream release refs before file-level audit collection.',
|
||||||
|
readOnly: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
command: 'git fetch origin --prune',
|
||||||
|
description: 'Refresh fork refs before comparing KT patch and upstream ranges.',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -270,6 +275,12 @@ export function buildNapcatUpstreamAudit(
|
|||||||
description: 'List KT fork patch files for deterministic overlap checks.',
|
description: 'List KT fork patch files for deterministic overlap checks.',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
command:
|
||||||
|
'git merge-tree "${FORK_BRANCH:-HEAD}" "${UPSTREAM_RELEASE_REF:-upstream/main}"',
|
||||||
|
description: 'Probe the dry merge shape without updating the worktree or refs.',
|
||||||
|
readOnly: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user