Skip to content
Closed
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions src/core/ignore/__tests__/RooIgnoreController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,33 @@ describe("RooIgnoreController", () => {
expect(emptyController.validateAccess("secrets/api-keys.json")).toBe(true)
expect(emptyController.validateAccess(".git/HEAD")).toBe(true)
})

/**
* Tests the specific scenario from GitHub issue #4647
* where .next folders should be properly ignored when specified in .rooignore
*/
it("should correctly ignore .next folders in nested projects (GitHub issue #4647)", async () => {
// Setup .rooignore content that matches the GitHub issue scenario
mockFileExists.mockResolvedValue(true)
mockReadFile.mockResolvedValue("example-nextjs/.next/")
await controller.initialize()

// Test files that should be ignored (in example-nextjs/.next/)
expect(controller.validateAccess("example-nextjs/.next/static/chunks/main.js")).toBe(false)
expect(controller.validateAccess("example-nextjs/.next/build-manifest.json")).toBe(false)
expect(controller.validateAccess("example-nextjs/.next/server/pages/index.js")).toBe(false)

// Test files that should be allowed
expect(controller.validateAccess("example-nextjs/src/app.js")).toBe(true)
expect(controller.validateAccess("example-nextjs/package.json")).toBe(true)
expect(controller.validateAccess("other-project/.next/file.js")).toBe(true)
expect(controller.validateAccess(".next/standalone-file.js")).toBe(true)

// Test that .git and .vscode are still handled by explicit ignore in listFiles
// (these should be allowed by RooIgnoreController since they're not in this .rooignore)
expect(controller.validateAccess(".git/config")).toBe(true)
expect(controller.validateAccess(".vscode/settings.json")).toBe(true)
})
})

describe("validateCommand", () => {
Expand Down
23 changes: 9 additions & 14 deletions src/services/glob/list-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const DIRS_TO_IGNORE = [
"deps",
"pkg",
"Pods",
".*",
".git",
".svn",
".hg",
".bzr",
".vscode",
".idea",
]

/**
Expand Down Expand Up @@ -156,14 +161,9 @@ function buildNonRecursiveArgs(): string[] {

// Apply directory exclusions for non-recursive searches
for (const dir of DIRS_TO_IGNORE) {
if (dir === ".*") {
// For hidden files/dirs in non-recursive mode
args.push("-g", "!.*")
} else {
// Direct children only
args.push("-g", `!${dir}`)
args.push("-g", `!${dir}/**`)
}
// Direct children only
args.push("-g", `!${dir}`)
args.push("-g", `!${dir}/**`)
}

return args
Expand Down Expand Up @@ -237,11 +237,6 @@ async function listFilteredDirectories(
* Determine if a directory should be included in results based on filters
*/
function shouldIncludeDirectory(dirName: string, recursive: boolean, gitignorePatterns: string[]): boolean {
// Skip hidden directories if configured to ignore them
if (dirName.startsWith(".") && DIRS_TO_IGNORE.includes(".*")) {
return false
}

// Check against explicit ignore patterns
if (isDirectoryExplicitlyIgnored(dirName)) {
return false
Expand Down
Loading