Просмотр исходного кода

fix(core): watch only git projects (#35957)

Co-authored-by: Kit Langton <kit.langton@gmail.com>
opencode-agent[bot] 2 месяцев назад
Родитель
Сommit
f95f877e5f

+ 1 - 1
packages/core/src/filesystem/watcher.ts

@@ -106,7 +106,7 @@ const layer = Layer.effect(
     const config = (yield* (yield* Config.Service).entries())
       .filter((entry): entry is Config.Document => entry.type === "document")
       .flatMap((item) => item.info.watcher?.ignore ?? [])
-    if (yield* Flag.OPENCODE_EXPERIMENTAL_FILEWATCHER) {
+    if (location.vcs && (yield* Flag.OPENCODE_EXPERIMENTAL_FILEWATCHER)) {
       yield* Effect.forkScoped(
         subscribe(location.directory, [...Ignore.PATTERNS, ...config, ...protecteds(location.directory)]),
       )

+ 6 - 7
packages/core/test/filesystem/watcher.test.ts

@@ -168,16 +168,12 @@ describeWatcher("Watcher", () => {
     ),
   )
 
-  it.live("watches non-git roots", () =>
+  it.live("skips non-git roots", () =>
     withTmp((directory) =>
       Effect.gen(function* () {
         const fs = yield* FSUtil.Service
         const file = path.join(directory, "plain.txt")
-        yield* ready(directory)
-        expect(yield* nextUpdate((event) => event.file === file, fs.writeFileString(file, "plain"))).toEqual({
-          file,
-          event: "add",
-        })
+        yield* noUpdate((event) => event.file === file, fs.writeFileString(file, "plain"))
       }),
     ),
   )
@@ -190,7 +186,10 @@ describeWatcher("Watcher", () => {
         Effect.promise(() => tmpdir()),
         (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
       )
-      yield* ready(tmp.path).pipe(provide(tmp.path), Effect.scoped)
+      yield* ready(tmp.path).pipe(
+        provide(tmp.path, { type: "git", store: AbsolutePath.make(path.join(tmp.path, ".git")) }),
+        Effect.scoped,
+      )
       const file = path.join(tmp.path, "after-dispose.txt")
       yield* noUpdate((event) => event.file === file, fs.writeFileString(file, "gone")).pipe(
         Effect.provideService(EventV2.Service, events),