@@ -75,17 +75,16 @@ def test_iter_build_context_files_respects_dockerignore(tmp_path: Path):
7575 assert "build/ignored.txt" not in files
7676
7777
78- def test_is_ignored_folder_exclusion_cannot_be_reincluded () -> None :
79- """Folder exclusion followed by file inclusion should still exclude.
80-
81- Mirrors Docker behavior exercised in moby's TestPatternMatchesFolderExclusions
82- style tests: a directory excluded by a pattern like ``docs`` cannot have
83- children re-included by a later ``!docs/README.md`` pattern.
84- """
78+ def test_is_ignored_directory_pattern_affects_directory_entry_only () -> None :
79+ """Directory patterns apply directly to directory entries, not to children."""
8580
8681 patterns = compile_ignore (["docs" , "!docs/README.md" ])
87- # The file under docs remains ignored overall.
88- assert is_ignored ("docs/README.md" , is_dir = False , patterns = patterns )
82+
83+ # The directory itself is ignored.
84+ assert is_ignored ("docs" , is_dir = True , patterns = patterns )
85+ # The child file is not ignored by the pattern set alone; directory pruning
86+ # in ``iter_included_files`` is responsible for excluding its contents.
87+ assert not is_ignored ("docs/README.md" , is_dir = False , patterns = patterns )
8988
9089
9190def test_compile_ignore_directory_only_and_files () -> None :
@@ -99,8 +98,10 @@ def test_compile_ignore_directory_only_and_files() -> None:
9998 assert not path_match (build_pat , "build" , is_dir = False )
10099 assert path_match (build_pat , "build" , is_dir = True )
101100
102- # But files under the directory are ignored via ancestor directory match.
103- assert is_ignored ("build/output.bin" , is_dir = False , patterns = patterns )
101+ # Files under the directory are not ignored purely by the directory-only
102+ # pattern; directory pruning in ``iter_included_files`` is responsible
103+ # for skipping their traversal.
104+ assert not is_ignored ("build/output.bin" , is_dir = False , patterns = patterns )
104105 # Log files are ignored everywhere.
105106 assert is_ignored ("app.log" , is_dir = False , patterns = patterns )
106107 assert is_ignored ("subdir/app.log" , is_dir = False , patterns = patterns )
0 commit comments