File tree 3 files changed +15
-0
lines changed
3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 44
44
- Black now uses the presence of debug f-strings to detect target version. (#3215 )
45
45
- Fix misdetection of project root and verbose logging of sources in cases involving
46
46
` --stdin-filename ` (#3216 )
47
+ - Immediate ` .gitignore ` files in source directories given on the command line are now
48
+ also respected, previously only ` .gitignore ` files in the project root and
49
+ automatically discovered directories were respected (#3237 )
47
50
48
51
### Documentation
49
52
Original file line number Diff line number Diff line change @@ -653,6 +653,11 @@ def get_sources(
653
653
if exclude is None :
654
654
exclude = re_compile_maybe_verbose (DEFAULT_EXCLUDES )
655
655
gitignore = get_gitignore (root )
656
+ p_gitignore = get_gitignore (p )
657
+ # No need to use p's gitignore if it is identical to root's gitignore
658
+ # (i.e. root and p point to the same directory).
659
+ if gitignore != p_gitignore :
660
+ gitignore += p_gitignore
656
661
else :
657
662
gitignore = None
658
663
sources .update (
Original file line number Diff line number Diff line change @@ -1990,6 +1990,13 @@ def test_nested_gitignore(self) -> None:
1990
1990
)
1991
1991
assert sorted (expected ) == sorted (sources )
1992
1992
1993
+ def test_nested_gitignore_directly_in_source_directory (self ) -> None :
1994
+ # https://github.com/psf/black/issues/2598
1995
+ path = Path (DATA_DIR / "nested_gitignore_tests" )
1996
+ src = Path (path / "root" / "child" )
1997
+ expected = [src / "a.py" , src / "c.py" ]
1998
+ assert_collected_sources ([src ], expected )
1999
+
1993
2000
def test_invalid_gitignore (self ) -> None :
1994
2001
path = THIS_DIR / "data" / "invalid_gitignore_tests"
1995
2002
empty_config = path / "pyproject.toml"
You can’t perform that action at this time.
0 commit comments