Skip to content

Match glob directory patterns in .thvignore - #7183

Closed
mansur-akhmadi wants to merge 1 commit into
stacklok:mainfrom
mansur-akhmadi:fix/thvignore-dir-glob
Closed

mansur-akhmadi wants to merge 1 commit into
stacklok:mainfrom
mansur-akhmadi:fix/thvignore-dir-glob

Conversation

@mansur-akhmadi

Copy link
Copy Markdown

Summary

A .thvignore pattern ending in / was only checked as a literal path, so a directory pattern with a wildcard (secrets-*/, *.egg-info/) never matched and those directories stayed visible in the mount, while the same pattern without the slash worked.

  • getMatchingPaths now handles directory patterns with the same literal-then-glob lookup as other patterns, and keeps only directories from the glob results.
  • An existing literal path still wins over glob expansion; a literal file under a directory pattern still matches nothing.

Fixes #7182

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)

  • E2E tests (task test-e2e)

  • Linting (task lint-fix)

  • Manual testing (describe below)

  • New table test TestGetMatchingPathsDirectoryPattern: glob matching several directories, glob matching only a file, glob matching nothing, literal file under a directory pattern, literal name with glob metacharacters (both a directory and a file), malformed glob. On main the glob case fails ([]string(nil) instead of the three directories); with the fix all pass.

  • go test -race -count=3 ./pkg/ignore/, plus ./pkg/container/docker/ ./pkg/container/runtime/ ./pkg/runtime/: ok.

  • golangci-lint v2.15.0 (the CI version) on ./pkg/ignore/...: 0 issues; go vet, gofmt: clean. I ran the package-scoped commands rather than the full task test / task lint.

Does this introduce a user-facing change?

Yes. Before: a .thvignore directory pattern with a wildcard hid nothing. After: it hides every matching directory at the top level of the mount (files matching it are left alone).

Special notes for reviewers

Not changed here: patterns still match only at the top level of the mount, without ** or ! support, as before.

A .thvignore pattern ending in "/" was only checked as a literal
path, so a directory pattern with a wildcard such as "secrets-*/" or
"*.egg-info/" never matched and the directories stayed visible in the
mount. Directory patterns now go through the same glob fallback as
other patterns, keeping only directories.

Signed-off-by: Mansur Akhmadi <[email protected]>
@jhrozek

jhrozek commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up, and sorry this one sat. #7258 fixed the same bug from #7182 and was merged today. It takes the same approach: glob the trimmed pattern and keep only directories. So I'm closing this as a duplicate. Your PR came in first, and the review order wasn't fair to you. Thanks for the clean fix.

@jhrozek jhrozek closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.thvignore directory patterns with wildcards never match

2 participants