Skip to content

Match .thvignore wildcard directory patterns - #7258

Merged
ChrisJBurns merged 1 commit into
stacklok:mainfrom
HankGrimm:fix/thvignore-wildcard-dir-pattern
Nov 25, 2026
Merged

ChrisJBurns merged 1 commit into
stacklok:mainfrom
HankGrimm:fix/thvignore-wildcard-dir-pattern

Conversation

@HankGrimm

Copy link
Copy Markdown
Contributor

Summary

getMatchingPaths returns early for any directory pattern ending in /,
only checking it as a literal path via os.Stat. A wildcard directory pattern
such as secrets-*/ or *.egg-info/ therefore never reaches the
filepath.Glob fallback and matches nothing, leaving the directories it should
hide visible in the container.

  • Glob the trimmed pattern when the literal directory does not exist.
  • Keep only directories, honoring the trailing slash's directory-only
    semantics.

Fixes #7182

Type of change

  • Bug fix

Test plan

  • Unit tests (task test) — added TestGetMatchingPathsWildcardDirectoryPattern
    (two matching dirs plus a same-prefix file, asserting the file is not matched);
    go test ./pkg/ignore/ passes for the new test.

Does this introduce a user-facing change?

Yes — a .thvignore directory pattern with a wildcard (e.g. secrets-*/,
*.egg-info/) now matches its directories and overlays them with empty
directories, as a non-wildcard directory pattern already did.

Special notes for reviewers

pkg/ignore has two pre-existing Windows-only failures (TestGetOverlayPaths,
TestGetOverlayMounts — path/overlay-artifact related), unrelated to this
change; they also fail on main on Windows.

🤖 Generated with Claude Code

getMatchingPaths returned early for any directory pattern (ending in a
slash), so a wildcard directory pattern such as secrets-*/ or *.egg-info/
never reached the filepath.Glob fallback and matched nothing.

Glob the trimmed pattern when the literal directory does not exist, keeping
only directories to honor the trailing slash's directory-only semantics.

Fixes stacklok#7182

Co-Authored-By: Claude Code <[email protected]>
@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.87%. Comparing base (ae8b232) to head (b9fca5d).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
pkg/ignore/processor.go 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7258      +/-   ##
==========================================
+ Coverage   81.81%   81.87%   +0.05%     
==========================================
  Files         914      914              
  Lines       92619    92626       +7     
==========================================
+ Hits        75773    75833      +60     
+ Misses      16841    16788      -53     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisJBurns

Copy link
Copy Markdown
Collaborator

/retest

@ChrisJBurns
ChrisJBurns merged commit 1041630 into stacklok:main Nov 25, 2026
73 of 74 checks passed
@jhrozek jhrozek mentioned this pull request Nov 25, 2026
3 of 10 tasks
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
2 tasks
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