From 945de4eddc249a6645b974525eed9f6795eac3aa Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Thu, 25 Sep 2025 06:38:59 -0500 Subject: [PATCH] wip: watch select .git files in watcher --- packages/opencode/src/cli/cmd/tui.ts | 2 -- packages/opencode/src/file/ignore.ts | 7 ++++--- packages/opencode/src/file/watcher.ts | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui.ts b/packages/opencode/src/cli/cmd/tui.ts index 16893311..119a8c78 100644 --- a/packages/opencode/src/cli/cmd/tui.ts +++ b/packages/opencode/src/cli/cmd/tui.ts @@ -9,7 +9,6 @@ import { Installation } from "../../installation" import { Config } from "../../config/config" import { Bus } from "../../bus" import { Log } from "../../util/log" -import { FileWatcher } from "../../file/watcher" import { Ide } from "../../ide" import { Flag } from "../../flag/flag" @@ -178,7 +177,6 @@ export const TuiCommand = cmd({ .then(() => Bus.publish(Ide.Event.Installed, { ide })) .catch(() => {}) })() - FileWatcher.init() await proc.exited server.stop() diff --git a/packages/opencode/src/file/ignore.ts b/packages/opencode/src/file/ignore.ts index 53e2003b..912f2159 100644 --- a/packages/opencode/src/file/ignore.ts +++ b/packages/opencode/src/file/ignore.ts @@ -6,9 +6,6 @@ export namespace FileIgnore { "**/.pnpm-store/**", "**/vendor/**", - // vcs - "**/.git/**", - // Build outputs "**/dist/**", "**/build/**", @@ -50,8 +47,12 @@ export namespace FileIgnore { filepath: string, opts: { extra?: Bun.Glob[] + whitelist?: Bun.Glob[] }, ) { + for (const glob of opts.whitelist || []) { + if (glob.match(filepath)) return false + } const extra = opts.extra || [] for (const glob of [...GLOBS, ...extra]) { if (glob.match(filepath)) return true diff --git a/packages/opencode/src/file/watcher.ts b/packages/opencode/src/file/watcher.ts index 84a80c0f..652cb785 100644 --- a/packages/opencode/src/file/watcher.ts +++ b/packages/opencode/src/file/watcher.ts @@ -30,6 +30,7 @@ export namespace FileWatcher { ignoreInitial: true, ignored: (filepath) => { return FileIgnore.match(filepath, { + whitelist: [new Bun.Glob("**/.git/{index,logs/HEAD}")], extra: ignore, }) },