Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/core/tests/git-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,19 @@ export function expectBlobsIntact(root: string, blobs: { oid: string; content: s
export function reflogs(root: string): string[] {
return git(root, "reflog", "show", "--all", "--format=%gd %H %gs").split("\n").filter(Boolean).sort();
}

/**
* `env` with commit and tag signing disabled at command scope, for a fixture
* whose product commands commit too. The entries go after any inherited
* `GIT_CONFIG_COUNT` ones, so they outrank global, repository and earlier
* environment configuration without touching the host's settings.
*/
export function withoutSigning(env: Record<string, string>): Record<string, string> {
const count = Number(env.GIT_CONFIG_COUNT ?? 0);
return {
...env,
GIT_CONFIG_COUNT: String(count + 2),
[`GIT_CONFIG_KEY_${count}`]: "commit.gpgSign", [`GIT_CONFIG_VALUE_${count}`]: "false",
[`GIT_CONFIG_KEY_${count + 1}`]: "tag.gpgSign", [`GIT_CONFIG_VALUE_${count + 1}`]: "false",
};
}
2 changes: 1 addition & 1 deletion packages/core/tests/hygiene-media.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ afterEach(() => {
});

function git(cwd: string, ...args: string[]): void {
const r = Bun.spawnSync(["git", "-C", cwd, ...args]);
const r = Bun.spawnSync(["git", "-c", "commit.gpgsign=false", "-C", cwd, ...args]);
if (r.exitCode !== 0) throw new Error(r.stderr.toString());
}
function put(root: string, path: string, text: string): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/media-inventory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const VOYAGE = ["pi", "voyage-home"];
const key = (backend: string, session: string) => JSON.stringify([backend, session]);

function git(cwd: string, ...args: string[]): void {
const r = Bun.spawnSync(["git", "-C", cwd, ...args]);
const r = Bun.spawnSync(["git", "-c", "commit.gpgsign=false", "-C", cwd, ...args]);
if (r.exitCode !== 0) throw new Error(r.stderr.toString());
}

Expand Down
9 changes: 8 additions & 1 deletion packages/core/tests/module-settings.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { afterEach, expect, test } from "bun:test";
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "fs";
import { join } from "path";
import { BRAIN_BIN, cleanup, keylessEnv, makeTempBrain, runCli } from "./cli-harness";
import { BRAIN_BIN, cleanup, keylessEnv as harnessEnv, makeTempBrain, runCli as harnessCli } from "./cli-harness";
import { withoutSigning } from "./git-fixture";

// Settings saves commit through the CLI. Every Git child, fixture and product
// alike, gets signing disabled at command scope, so no ambient signing
// configuration reaches these temporary repositories.
const keylessEnv = (root: string) => withoutSigning(harnessEnv(root));
const runCli = (root: string, args: string[]) => harnessCli(root, args, keylessEnv(root));

const roots: string[] = [];
afterEach(() => { for (const root of roots.splice(0)) cleanup(root); });
Expand Down
9 changes: 8 additions & 1 deletion packages/module-jobs/tests/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ import { frontmatterEngineSentinel } from "../../../tests/helpers/frontmatter-en
import { afterEach, expect, test } from "bun:test";
import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "fs";
import { join } from "path";
import { cleanup, keylessEnv, makeTempBrain, runCli } from "../../core/tests/cli-harness";
import { cleanup, keylessEnv as harnessEnv, makeTempBrain, runCli as harnessCli } from "../../core/tests/cli-harness";
import { withoutSigning } from "../../core/tests/git-fixture";
import { parseFrontmatter } from "@schlessera/brain-common/internal/frontmatter";
import { configSchema } from "../src/module";
import { jobsSettings, planScoringMigration } from "../src/settings";
import { loadScoringConfig, parseScoringConfig, scoreJob } from "../src/score";
import { ADAPTERS, getAdapterOptions } from "../src/scrape";

// Settings saves commit through the CLI. Every Git child, fixture and product
// alike, gets signing disabled at command scope, so no ambient signing
// configuration reaches these temporary repositories.
const keylessEnv = (root: string) => withoutSigning(harnessEnv(root));
const runCli = (root: string, args: string[]) => harnessCli(root, args, keylessEnv(root));

const roots: string[] = [];
afterEach(() => { for (const root of roots.splice(0)) cleanup(root); });
const source = readFileSync(join(import.meta.dir, "fixtures/criteria.md"), "utf8");
Expand Down
Loading