@@ -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,12 @@ 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
+ if ($ baseDir !== '' ) {
55
+ $ baseDir = $ this ->tmpDir . '/ ' . $ baseDir ;
56
+ } else {
57
+ $ baseDir = $ this ->tmpDir ;
58
+ }
59
+ $ iterator = new VcsIgnoredFilterIterator ($ inner , $ baseDir );
55
60
56
61
$ this ->assertIterator ($ this ->toAbsolute ($ expectedResult ), $ iterator );
57
62
}
@@ -74,6 +79,55 @@ public static function getAcceptData(): iterable
74
79
],
75
80
];
76
81
82
+ yield 'simple file - .gitignore and in() from repository root ' => [
83
+ [
84
+ '.gitignore ' => 'a.txt ' ,
85
+ ],
86
+ [
87
+ '.git ' ,
88
+ 'a.txt ' ,
89
+ 'b.txt ' ,
90
+ 'dir/ ' ,
91
+ 'dir/a.txt ' ,
92
+ ],
93
+ [
94
+ '.git ' ,
95
+ 'b.txt ' ,
96
+ 'dir ' ,
97
+ ],
98
+ ];
99
+
100
+ yield 'nested git repositories only consider .gitignore files of the most inner repository ' => [
101
+ [
102
+ '.gitignore ' => "nested/* \na.txt " ,
103
+ 'nested/.gitignore ' => 'c.txt ' ,
104
+ 'nested/dir/.gitignore ' => 'f.txt ' ,
105
+ ],
106
+ [
107
+ '.git ' ,
108
+ 'a.txt ' ,
109
+ 'b.txt ' ,
110
+ 'nested/ ' ,
111
+ 'nested/.git ' ,
112
+ 'nested/c.txt ' ,
113
+ 'nested/d.txt ' ,
114
+ 'nested/dir/ ' ,
115
+ 'nested/dir/e.txt ' ,
116
+ 'nested/dir/f.txt ' ,
117
+ ],
118
+ [
119
+ '.git ' ,
120
+ 'a.txt ' ,
121
+ 'b.txt ' ,
122
+ 'nested ' ,
123
+ 'nested/.git ' ,
124
+ 'nested/d.txt ' ,
125
+ 'nested/dir ' ,
126
+ 'nested/dir/e.txt ' ,
127
+ ],
128
+ 'nested ' ,
129
+ ];
130
+
77
131
yield 'simple file at root ' => [
78
132
[
79
133
'.gitignore ' => '/a.txt ' ,
0 commit comments