style: prettier pass

This commit is contained in:
wdawdwa committed 2026-08-22 18:06:37 +08:00
1 parent dcaa27db9a
commit 594592046b
8 files changed
+35 -25

No files matched your search

+4 -1
View File
@@ -45,7 +45,10 @@ export class GooseReviewer {
input.files.map((file) => file.filename) input.files.map((file) => file.filename)
); );
if (warnings.length > 0) { if (warnings.length > 0) {
logger.warn({ warnings }, "Review output contained findings that could not be posted inline."); logger.warn(
{ warnings },
"Review output contained findings that could not be posted inline."
);
} }
return decision; return decision;
}, },
+8 -2
View File
@@ -943,7 +943,10 @@ async function maybeMergePullRequest(
// A concurrent schedule run or approval event may have merged this head // A concurrent schedule run or approval event may have merged this head
// first. GitHub answers 405 with "was already merged"; treat it as done. // first. GitHub answers 405 with "was already merged"; treat it as done.
if (isAlreadyMergedError(error)) { if (isAlreadyMergedError(error)) {
logger.info({ owner, repo, pullNumber, headSha: params.headSha }, "Pull request was already merged by a concurrent run."); logger.info(
{ owner, repo, pullNumber, headSha: params.headSha },
"Pull request was already merged by a concurrent run."
);
return; return;
} }
throw error; throw error;
@@ -958,7 +961,10 @@ function isAlreadyMergedError(error: unknown): boolean {
if (candidate.status !== 405 && candidate.status !== 409) { if (candidate.status !== 405 && candidate.status !== 409) {
return false; return false;
} }
return typeof candidate.message === "string" && /already.{0,20}merged|Pull Request is not mergeable/i.test(candidate.message); return (
typeof candidate.message === "string" &&
/already.{0,20}merged|Pull Request is not mergeable/i.test(candidate.message)
);
} }
async function hasCurrentHeadApprovalFrom( async function hasCurrentHeadApprovalFrom(
+1 -3
View File
@@ -39,9 +39,7 @@ test("toDiffPosition maps valid new lines and rejects stale ones", () => {
}); });
test("hunk headers with ranges are parsed correctly", () => { test("hunk headers with ranges are parsed correctly", () => {
const valid = collectValidNewLines([ const valid = collectValidNewLines([file("@@ -10,5 +20,3 @@\n+first\n+second\n+third")]);
file("@@ -10,5 +20,3 @@\n+first\n+second\n+third")
]);
assert.equal(valid.has("src/a.ts:20"), true); assert.equal(valid.has("src/a.ts:20"), true);
assert.equal(valid.has("src/a.ts:22"), true); assert.equal(valid.has("src/a.ts:22"), true);
assert.equal(valid.has("src/a.ts:23"), false); assert.equal(valid.has("src/a.ts:23"), false);
+2 -8
View File
@@ -8,14 +8,8 @@ import {
} from "../src/storage/cacheStore.js"; } from "../src/storage/cacheStore.js";
test("object keys are scoped by repository id, pull number, and optional prefix", () => { test("object keys are scoped by repository id, pull number, and optional prefix", () => {
assert.equal( assert.equal(repositoryKnowledgeObjectKey("123"), "repositories/123/knowledge/repository.md");
repositoryKnowledgeObjectKey("123"), assert.equal(pullRequestReviewObjectKey("123", 7), "repositories/123/pulls/7/latest.json");
"repositories/123/knowledge/repository.md"
);
assert.equal(
pullRequestReviewObjectKey("123", 7),
"repositories/123/pulls/7/latest.json"
);
assert.equal( assert.equal(
pullRequestReviewObjectKey("123", 7, "forum-1"), pullRequestReviewObjectKey("123", 7, "forum-1"),
"forum-1/repositories/123/pulls/7/latest.json" "forum-1/repositories/123/pulls/7/latest.json"
+4 -1
View File
@@ -20,7 +20,10 @@ test("repository knowledge round trips through the agent scratch file", async ()
// container-facing 0o777/0o666 contract can only be asserted on POSIX. // container-facing 0o777/0o666 contract can only be asserted on POSIX.
if (process.platform === "win32") { if (process.platform === "win32") {
assert.equal((await fs.stat(path.join(root, ".ghbot"))).mode & 0o222, 0o222); assert.equal((await fs.stat(path.join(root, ".ghbot"))).mode & 0o222, 0o222);
assert.equal((await fs.stat(path.join(root, ".ghbot", "repository-knowledge.md"))).mode & 0o222, 0o222); assert.equal(
(await fs.stat(path.join(root, ".ghbot", "repository-knowledge.md"))).mode & 0o222,
0o222
);
} else { } else {
assert.equal((await fs.stat(path.join(root, ".ghbot"))).mode & 0o777, 0o777); assert.equal((await fs.stat(path.join(root, ".ghbot"))).mode & 0o777, 0o777);
assert.equal( assert.equal(
+6 -8
View File
@@ -52,20 +52,18 @@ test("throws the last error after exhausting attempts", async () => {
}, },
{ maxAttempts: 3, baseDelayMs: 1 } { maxAttempts: 3, baseDelayMs: 1 }
), ),
/boom 3$/ /boom 3$/
); );
assert.equal(attempts, 3); assert.equal(attempts, 3);
}); });
test("4xx errors are not retried by default", async () => { test("4xx errors are not retried by default", async () => {
let attempts = 0; let attempts = 0;
await assert.rejects( await assert.rejects(
withRetry( withRetry("probe.client-error", async () => {
"probe.client-error", attempts += 1;
async () => { throw new HttpLikeError(404, "not found");
attempts += 1; })
throw new HttpLikeError(404, "not found");
})
); );
assert.equal(attempts, 1); assert.equal(attempts, 1);
}); });
+2 -1
View File
@@ -54,7 +54,8 @@ test("a clean decision submits a single final APPROVE review", () => {
}); });
test("superseded review bodies keep the original state marker", () => { test("superseded review bodies keep the original state marker", () => {
const marker = "<!-- ghbot-review:v1 mode=normal outcome=pass requires-admin=false review=0 change=0 -->"; const marker =
"<!-- ghbot-review:v1 mode=normal outcome=pass requires-admin=false review=0 change=0 -->";
const body = formatSupersededReviewBody({ const body = formatSupersededReviewBody({
originalMarker: marker, originalMarker: marker,
oldCommitId: "a".repeat(40), oldCommitId: "a".repeat(40),
+8 -1
View File
@@ -9,7 +9,14 @@ import {
import { containsSecret, redactSecrets } from "../src/security/secrets.js"; import { containsSecret, redactSecrets } from "../src/security/secrets.js";
test("protected basenames cover env files, agent configs, and deploy configs", () => { test("protected basenames cover env files, agent configs, and deploy configs", () => {
for (const name of [".env", ".env.local", ".ENV", "AGENTS.MD", "opencode.json", "wrangler.toml"]) { for (const name of [
".env",
".env.local",
".ENV",
"AGENTS.MD",
"opencode.json",
"wrangler.toml"
]) {
assert.equal(isProtectedBasename(name), true, `${name} should be protected`); assert.equal(isProtectedBasename(name), true, `${name} should be protected`);
} }
assert.equal(isProtectedBasename("environment.ts"), false); assert.equal(isProtectedBasename("environment.ts"), false);