Skip to content
Closed
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
18 changes: 18 additions & 0 deletions bin/gstack-gbrain-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,24 @@ async function runCodeImport(args: CliArgs): Promise<StageResult> {
};
}

// After a successful attach, ensure .gbrain-source is in the consumer repo's
// .gitignore. The v1.29.0.0 changelog promised this; the original patch only
// added it to gstack's own .gitignore, not the consuming repo's. Without this,
// `git add -A` in any Conductor sibling worktree can commit the pin and silently
// override other worktrees' per-worktree source IDs on next pull.
try {
const gitignorePath = join(root, ".gitignore");
let existing = "";
try { existing = readFileSync(gitignorePath, "utf-8"); } catch { /* will create */ }
if (!existing.split("\n").some((line) => line.trim() === ".gbrain-source")) {
const sep = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
writeFileSync(gitignorePath, existing + sep + ".gbrain-source\n");
}
} catch {
// Non-fatal — unwritable .gitignore (read-only checkout, weird perms) should
// not fail the stage. The user will need to add the entry manually.
}

return {
name: "code",
ran: true,
Expand Down