@@ -34,7 +34,7 @@ protected function tearDown(): void
34
34
*
35
35
* @dataProvider getAcceptData
36
36
*/
37
- public function testAccept (array $ gitIgnoreFiles , array $ otherFileNames , array $ expectedResult )
37
+ public function testAccept (array $ gitIgnoreFiles , array $ otherFileNames , array $ expectedResult, string $ baseDir = '' )
38
38
{
39
39
$ otherFileNames = $ this ->toAbsolute ($ otherFileNames );
40
40
foreach ($ otherFileNames as $ path ) {
@@ -51,7 +51,8 @@ public function testAccept(array $gitIgnoreFiles, array $otherFileNames, array $
51
51
52
52
$ inner = new InnerNameIterator ($ otherFileNames );
53
53
54
- $ iterator = new VcsIgnoredFilterIterator ($ inner , $ this ->tmpDir );
54
+ $ baseDir = $ this ->tmpDir .('' !== $ baseDir ? '/ ' .$ baseDir : '' );
55
+ $ iterator = new VcsIgnoredFilterIterator ($ inner , $ baseDir );
55
56
56
57
$ this ->assertIterator ($ this ->toAbsolute ($ expectedResult ), $ iterator );
57
58
}
@@ -74,6 +75,55 @@ public static function getAcceptData(): iterable
74
75
],
75
76
];
76
77
78
+ yield 'simple file - .gitignore and in() from repository root ' => [
79
+ [
80
+ '.gitignore ' => 'a.txt ' ,
81
+ ],
82
+ [
83
+ '.git ' ,
84
+ 'a.txt ' ,
85
+ 'b.txt ' ,
86
+ 'dir/ ' ,
87
+ 'dir/a.txt ' ,
88
+ ],
89
+ [
90
+ '.git ' ,
91
+ 'b.txt ' ,
92
+ 'dir ' ,
93
+ ],
94
+ ];
95
+
96
+ yield 'nested git repositories only consider .gitignore files of the most inner repository ' => [
97
+ [
98
+ '.gitignore ' => "nested/* \na.txt " ,
99
+ 'nested/.gitignore ' => 'c.txt ' ,
100
+ 'nested/dir/.gitignore ' => 'f.txt ' ,
101
+ ],
102
+ [
103
+ '.git ' ,
104
+ 'a.txt ' ,
105
+ 'b.txt ' ,
106
+ 'nested/ ' ,
107
+ 'nested/.git ' ,
108
+ 'nested/c.txt ' ,
109
+ 'nested/d.txt ' ,
110
+ 'nested/dir/ ' ,
111
+ 'nested/dir/e.txt ' ,
112
+ 'nested/dir/f.txt ' ,
113
+ ],
114
+ [
115
+ '.git ' ,
116
+ 'a.txt ' ,
117
+ 'b.txt ' ,
118
+ 'nested ' ,
119
+ 'nested/.git ' ,
120
+ 'nested/d.txt ' ,
121
+ 'nested/dir ' ,
122
+ 'nested/dir/e.txt ' ,
123
+ ],
124
+ 'nested ' ,
125
+ ];
126
+
77
127
yield 'simple file at root ' => [
78
128
[
79
129
'.gitignore ' => '/a.txt ' ,
0 commit comments