Skip to content

Fix .juliabundleignore: directory patterns, comments, and content exclusion#137

Open
xtalax wants to merge 1 commit intoJuliaComputing:mainfrom
xtalax:fix/bundleignore-directory-patterns
Open

Fix .juliabundleignore: directory patterns, comments, and content exclusion#137
xtalax wants to merge 1 commit intoJuliaComputing:mainfrom
xtalax:fix/bundleignore-directory-patterns

Conversation

@xtalax
Copy link
Copy Markdown

@xtalax xtalax commented Apr 10, 2026

Summary

  • Directory patterns (e.g. output-data/) now correctly exclude all files inside the directory, not just the directory entry itself. Previously, Glob.FilenameMatch("output-data/") only matched the literal string and files inside were still bundled.
  • Comments (# ...) and blank lines in .juliabundleignore are now properly skipped instead of being compiled into glob patterns.
  • File/directory ambiguity fixed: a pattern foo.csv/ no longer incorrectly excludes a file named foo.csv (only matches if it's actually a directory).

Root cause

get_bundleignore passed every line through Glob.FilenameMatch() without filtering. Glob.FilenameMatch("output-data/") matches the literal string "output-data/" but NOT "output-data/foo.jld2" — so files inside ignored directories were silently bundled.

Fix

New _parse_bundleignore_line() classifies each line:

  • nothing for comments/blanks (skipped)
  • String for plain directory prefixes → matched via startswith
  • Glob.FilenameMatch for glob patterns (unchanged behavior)
  • Glob-containing directory patterns (e.g. */bar/) emit both the dir match and a pattern* contents match

Test plan

  • Existing path_filterer tests updated (removed "known limitation" comments — the limitation is now fixed)
  • Existing fixtures/bundle1 integration tests all pass (22/22 including directory exclusion)
  • All bundle.* test sets pass (0 failures)

Relates to #130 (negated paths — this PR cleans up the same code path and is a prerequisite).

🤖 Generated with Claude Code

@xtalax
Copy link
Copy Markdown
Author

xtalax commented Apr 10, 2026

This is something I came up against a few months ago, claude was able to fix.

The problem was failing to exclude items inside of directories as well as directories.

…lusion

Three bugs in the bundleignore parser:

1. Directory patterns (e.g. "output-data/") were compiled into
   Glob.FilenameMatch which only matched the literal string, not files
   inside the directory. A pattern "foo/" would exclude the entry "foo/"
   but NOT "foo/bar.jl".

   Fix: plain directory prefixes (no glob chars) are matched via
   startswith(). Glob-containing directory patterns (e.g. "*/bar/")
   emit both the dir match and a "*/bar/*" contents match.

2. Comment lines (starting with #) and blank lines were compiled into
   Glob.FilenameMatch patterns, potentially causing spurious matches.

   Fix: _parse_bundleignore_line() skips comments and blanks.

3. A file named "foo.csv" could be incorrectly excluded by a directory
   pattern "foo.csv/" because joinpath("foo.csv", "") == "foo.csv/".

   Fix: the rpath_dir startswith check is only applied when the path
   is actually a directory (isdir guard).

Updates existing tests to reflect the corrected behavior: files inside
directories matched by "*/bar/" patterns are now properly excluded.

Relates to JuliaComputing#130 (negated paths — this fix is a prerequisite, cleaning
up the same code path).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@xtalax xtalax force-pushed the fix/bundleignore-directory-patterns branch from d735e9f to a44c029 Compare April 10, 2026 19:21
@pfitzseb pfitzseb self-requested a review April 14, 2026 15:55
@pfitzseb
Copy link
Copy Markdown
Member

Do you have a reproducer for the original issue? We have test coverage for this and explicitly check that files in excluded directories are not present in the bundle:

@testset "directories" begin
write(
joinpath(bundle_root, ".juliabundleignore"),
"""
output-data/
foo.csv/
""",
)
files = bundle_and_file_listing(bundle_root)
@test files == [
"bundle1/.juliabundleignore",
"bundle1/Manifest.toml",
"bundle1/Project.toml",
"bundle1/dir1/binary.exe",
"bundle1/dir1/foo.csv",
"bundle1/foo.csv",
"bundle1/keys.private",
"bundle1/script.jl",
"bundle1/settings.json",
"bundle1/subignore/keys.private",
"bundle1/subignore/readme.txt",
"bundle1/xyz.exe",
]
end

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.

2 participants