fix(core): skip nested repositories in snapshots

This commit is contained in:
rekram1-node
2026-08-22 21:45:31 +00:00
parent f282a22d98
commit 5752d74cae
2 changed files with 29 additions and 1 deletions
+1 -1
View File
@@ -397,7 +397,7 @@ const layer = Layer.effect(
],
{ concurrency: 2 },
)
const candidates = Array.from(new Set([...tracked, ...untracked]))
const candidates = Array.from(new Set([...tracked, ...untracked])).filter((item) => !item.endsWith("/"))
if (!candidates.length) return { skipped: [] }
const ignored = input.ignores
? new Set(
+28
View File
@@ -131,6 +131,34 @@ describe("Git worktrees", () => {
})
describe("Git trees", () => {
it.live("skips untracked nested repositories without commits", () =>
Effect.gen(function* () {
const root = yield* Effect.acquireRelease(
Effect.promise(() => tmpdir()),
(dir) => Effect.promise(() => dir[Symbol.asyncDispose]()),
)
const storage = AbsolutePath.make(`${root.path}-snapshot`)
yield* Effect.addFinalizer(() => Effect.promise(() => fs.rm(storage, { recursive: true, force: true })))
yield* Effect.promise(async () => {
await initRepo(root.path)
await fs.mkdir(path.join(root.path, "tui"))
await $`git init`.cwd(path.join(root.path, "tui")).quiet()
await fs.writeFile(path.join(root.path, "tui", "nested.txt"), "nested\n")
await fs.writeFile(path.join(root.path, "added.txt"), "added\n")
})
const git = yield* Git.Service
const source = yield* git.repo.discover(AbsolutePath.make(root.path))
if (!source) throw new Error("Repository not found")
const repository = yield* git.repo.create({ worktree: source.worktree, gitDirectory: storage, seed: source })
const before = yield* git.tree.write(repository)
yield* git.index.refresh({ repository, scope: RelativePath.make(".") })
const after = yield* git.tree.write(repository)
expect(yield* git.tree.files({ repository, from: before, to: after })).toEqual([RelativePath.make("added.txt")])
}),
)
it.live("captures, compares, previews, and restores scoped trees", () =>
Effect.gen(function* () {
const root = yield* Effect.acquireRelease(