Browse Source

tweak: adjust git watcher to ignore files other than HEAD

Aiden Cline 1 month ago
parent
commit
02e5a19242
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/opencode/src/file/watcher.ts

+ 4 - 1
packages/opencode/src/file/watcher.ts

@@ -12,6 +12,7 @@ import { lazy } from "@/util/lazy"
 import type ParcelWatcher from "@parcel/watcher"
 import { $ } from "bun"
 import { Flag } from "@/flag/flag"
+import { readdir } from "fs/promises"
 
 declare const OPENCODE_LIBC: string | undefined
 
@@ -78,9 +79,11 @@ export namespace FileWatcher {
         .text()
         .then((x) => path.resolve(Instance.worktree, x.trim()))
       if (vcsDir && !cfgIgnores.includes(".git") && !cfgIgnores.includes(vcsDir)) {
+        const gitDirContents = await readdir(vcsDir).catch(() => [])
+        const ignoreList = gitDirContents.filter((entry) => entry !== "HEAD")
         subs.push(
           await watcher().subscribe(vcsDir, subscribe, {
-            ignore: ["hooks", "info", "logs", "objects", "refs", "worktrees", "modules", "lfs"],
+            ignore: ignoreList,
             backend,
           }),
         )