Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

fix: honor --no-gitignore when saving build options (#413)

s4kurae447ee3b93d4
diff --git a/src/util/state.ts b/src/util/state.ts
index b17de7a9..fd011cac 100644
--- a/src/util/state.ts
+++ b/src/util/state.ts
@@ -117,6 +117,8 @@ export function buildConfigPath(d: string): string { return join(d, BUILD_CONFIG
/** Keep local build configuration out of Git without coupling it to the
* generated graph directory. Best-effort, matching graph-cache ignore setup. */
function ensureBuildConfigIgnored(d: string): void {
+ const noGitignore = process.env.GRAFT_NO_GITIGNORE;
+ if (noGitignore && noGitignore !== '0' && noGitignore !== 'false') return;
const path = join(d, '.gitignore');
let current = '';
try { current = readFileSync(path, 'utf8'); } catch { /* no .gitignore yet */ }
diff --git a/test/util-state.test.ts b/test/util-state.test.ts
index da6e75ea..ab723043 100644
--- a/test/util-state.test.ts
+++ b/test/util-state.test.ts
@@ -7,7 +7,7 @@
*/
import { test } from "node:test";
import assert from "node:assert/strict";
-import { existsSync, mkdtempSync, readFileSync } from "node:fs";
+import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
@@ -41,6 +41,26 @@ test("writeBuildConfig + readBuildConfig round-trip includeDirs", () => {
assert.match(readFileSync(join(d, ".gitignore"), "utf8"), /^\/\.graft\/$/m);
});
+test("writeBuildConfig respects GRAFT_NO_GITIGNORE while persisting build choices", () => {
+ const d = fresh();
+ const ignore = join(d, ".gitignore");
+ writeFileSync(ignore, "build/\n");
+ const previous = process.env.GRAFT_NO_GITIGNORE;
+ try {
+ process.env.GRAFT_NO_GITIGNORE = "1";
+ writeBuildConfig(d, { followSubmodules: true });
+ assert.equal(readFileSync(ignore, "utf8"), "build/\n");
+ assert.deepEqual(readBuildConfig(d), { followSubmodules: true });
+
+ process.env.GRAFT_NO_GITIGNORE = "0";
+ writeBuildConfig(d, { followSubmodules: false });
+ assert.match(readFileSync(ignore, "utf8"), /^\/\.graft\/$/m);
+ } finally {
+ if (previous === undefined) delete process.env.GRAFT_NO_GITIGNORE;
+ else process.env.GRAFT_NO_GITIGNORE = previous;
+ }
+});
+
test("readIncludeDirs turns a persisted list into a Set; an empty persisted list reads as undefined (default behavior)", () => {
const d = fresh();
writeBuildConfig(d, { includeDirs: ["build"] });