Skip to content

Commit 813f6b3

Browse files
committed
merged branch jocl/master (PR symfony#4211)
Commits ------- d3fee9b [Finder] ignoreDotFiles(true) filter does not match (issue symfony#4106) Discussion ---------- Fix for issue symfony#4106 [Finder] ignoreDotFiles(true) filter does not match I added new dot test files: * .bar * .foo/ * .foo/.bar Changed the tests and made a fix to finder that seems to okay for me. I hope my first PR is well arranged ;-) If not I will be pleased to get feedback... --------------------------------------------------------------------------- by vicb at 2012-05-11T10:20:51Z Could you squash you commits ? There is also an issue when `ignoreDotFiles(false)` is called twice, could you add a failing TC and fix the code ? `$this->ignore = $this->ignore ^ static::IGNORE_DOT_FILES;` should be `$this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;` --------------------------------------------------------------------------- by travisbot at 2012-05-11T12:43:53Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1304510) (merged 72c320bc into ff7c475). --------------------------------------------------------------------------- by vicb at 2012-05-11T13:09:32Z You need to: - tackle the related issue I have mentioned, - squash the commit, - rebase, - force push to your branch. http://symfony.com/doc/current/contributing/code/patches.html has some more info. As a fix, did you consider sending it to the 2.0 branch - your mention it as a BC in the commit comment but it really is a bug fix. --------------------------------------------------------------------------- by jocl at 2012-05-11T13:33:30Z Thank you. I will try it. Hasn't ```ignoreVCS(false)``` the same twice calling problem with ```$this->ignore = $this->ignore ^ static::IGNORE_VCS_FILES;```? --------------------------------------------------------------------------- by vicb at 2012-05-11T13:36:22Z yep, good catch ! --------------------------------------------------------------------------- by jocl at 2012-05-12T10:32:06Z I mentioned it as BC, since I found no place in documentation with the information that dotFiles are ignored by default. I was also wondering that it is default behavior. But if I only read the code, it is a 100% bug. As soon as the PR is merged, I think we should also add a little notice in documentation like it is for ignoreVCS(): http://symfony.com/doc/master/components/finder.html#files-or-directories --------------------------------------------------------------------------- by fabpot at 2012-05-15T05:47:49Z I think you should keep these changes on master. Last thing before I can merge: can you squash your commits as explained by @vicb? --------------------------------------------------------------------------- by travisbot at 2012-05-15T08:20:04Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1334337) (merged 525919fa into ff7c475). --------------------------------------------------------------------------- by jocl at 2012-05-15T08:23:24Z I am sorry, of wasting your time... totally confused about using git. I feel a little bit squashed :-) of a the possible actions. I hope it is squashed now. And next time I will use the issue/ticket branch I made. --------------------------------------------------------------------------- by fabpot at 2012-05-15T08:35:59Z That's still not good. Squashing is explained here: http://symfony.com/doc/current/contributing/code/patches.html#rework-your-patch --------------------------------------------------------------------------- by travisbot at 2012-05-15T20:44:14Z This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1339390) (merged d3fee9b into 03d4b02).
2 parents e351c9f + d3fee9b commit 813f6b3

9 files changed

+41
-22
lines changed

src/Symfony/Component/Finder/Finder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function ignoreDotFiles($ignoreDotFiles)
290290
if ($ignoreDotFiles) {
291291
$this->ignore = $this->ignore | static::IGNORE_DOT_FILES;
292292
} else {
293-
$this->ignore = $this->ignore ^ static::IGNORE_DOT_FILES;
293+
$this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;
294294
}
295295

296296
return $this;
@@ -312,7 +312,7 @@ public function ignoreVCS($ignoreVCS)
312312
if ($ignoreVCS) {
313313
$this->ignore = $this->ignore | static::IGNORE_VCS_FILES;
314314
} else {
315-
$this->ignore = $this->ignore ^ static::IGNORE_VCS_FILES;
315+
$this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES;
316316
}
317317

318318
return $this;
@@ -595,7 +595,7 @@ private function searchInDirectory($dir)
595595
}
596596

597597
if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
598-
$this->exclude[] = '\..+';
598+
$this->notNames[] = '/^\..+/';
599599
}
600600

601601
if ($this->exclude) {

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,33 @@ public function testExclude()
129129
public function testIgnoreVCS()
130130
{
131131
$finder = new Finder();
132-
$this->assertSame($finder, $finder->ignoreVCS(false));
133-
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
132+
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
133+
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
134134

135135
$finder = new Finder();
136-
$this->assertSame($finder, $finder->ignoreVCS(true));
137-
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
136+
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
137+
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
138+
139+
$finder = new Finder();
140+
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
141+
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
142+
138143
}
139144

140145
public function testIgnoreDotFiles()
141146
{
142147
$finder = new Finder();
143148
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
144-
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
149+
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
150+
151+
$finder = new Finder();
152+
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
153+
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
145154

146155
$finder = new Finder();
147-
$this->assertSame($finder, $finder->ignoreDotFiles(true));
156+
$this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
148157
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
158+
149159
}
150160

151161
public function testSortByName()

src/Symfony/Component/Finder/Tests/Iterator/DateRangeFilterIteratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public function testAccept($size, $expected)
3131
public function getAcceptData()
3232
{
3333
return array(
34-
array(array(new DateComparator('since 20 years ago')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto')),
35-
array(array(new DateComparator('since 2 months ago')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/toto')),
36-
array(array(new DateComparator('until last month')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto')),
34+
array(array(new DateComparator('since 20 years ago')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto', sys_get_temp_dir().'/symfony2_finder/.bar', sys_get_temp_dir().'/symfony2_finder/.foo', sys_get_temp_dir().'/symfony2_finder/.foo/.bar')),
35+
array(array(new DateComparator('since 2 months ago')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/toto', sys_get_temp_dir().'/symfony2_finder/.bar', sys_get_temp_dir().'/symfony2_finder/.foo', sys_get_temp_dir().'/symfony2_finder/.foo/.bar')),
36+
array(array(new DateComparator('until last month')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto', sys_get_temp_dir().'/symfony2_finder/.foo')),
3737
);
3838
}
3939
}

src/Symfony/Component/Finder/Tests/Iterator/DepthRangeIteratorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public function testAccept($size, $expected)
3434
public function getAcceptData()
3535
{
3636
return array(
37-
array(array(new NumberComparator('< 1')), array($this->getAbsolutePath('/.git'), $this->getAbsolutePath('/test.py'), $this->getAbsolutePath('/foo'), $this->getAbsolutePath('/test.php'), $this->getAbsolutePath('/toto'))),
38-
array(array(new NumberComparator('<= 1')), array($this->getAbsolutePath('/.git'), $this->getAbsolutePath('/test.py'), $this->getAbsolutePath('/foo'), $this->getAbsolutePath('/foo/bar.tmp'), $this->getAbsolutePath('/test.php'), $this->getAbsolutePath('/toto'))),
37+
array(array(new NumberComparator('< 1')), array($this->getAbsolutePath('/.git'), $this->getAbsolutePath('/test.py'), $this->getAbsolutePath('/foo'), $this->getAbsolutePath('/test.php'), $this->getAbsolutePath('/toto'), $this->getAbsolutePath('/.foo'), $this->getAbsolutePath('/.bar'))),
38+
array(array(new NumberComparator('<= 1')), array($this->getAbsolutePath('/.git'), $this->getAbsolutePath('/test.py'), $this->getAbsolutePath('/foo'), $this->getAbsolutePath('/foo/bar.tmp'), $this->getAbsolutePath('/test.php'), $this->getAbsolutePath('/toto'), $this->getAbsolutePath('/.foo'), $this->getAbsolutePath('/.foo/.bar'), $this->getAbsolutePath('/.bar'))),
3939
array(array(new NumberComparator('> 1')), array()),
40-
array(array(new NumberComparator('>= 1')), array($this->getAbsolutePath('/foo/bar.tmp'))),
41-
array(array(new NumberComparator('1')), array($this->getAbsolutePath('/foo/bar.tmp'))),
40+
array(array(new NumberComparator('>= 1')), array($this->getAbsolutePath('/foo/bar.tmp'), $this->getAbsolutePath('/.foo/.bar'))),
41+
array(array(new NumberComparator('1')), array($this->getAbsolutePath('/foo/bar.tmp'), $this->getAbsolutePath('/.foo/.bar'))),
4242
);
4343
}
4444

src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFileIteratorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ public function getAcceptData()
3333

3434
return array(
3535
array(array('foo'), array(
36+
$tmpDir.DIRECTORY_SEPARATOR.'.bar',
37+
$tmpDir.DIRECTORY_SEPARATOR.'.foo',
38+
$tmpDir.DIRECTORY_SEPARATOR.'.foo'.DIRECTORY_SEPARATOR.'.bar',
3639
$tmpDir.DIRECTORY_SEPARATOR.'.git',
3740
$tmpDir.DIRECTORY_SEPARATOR.'test.py',
3841
$tmpDir.DIRECTORY_SEPARATOR.'test.php',
3942
$tmpDir.DIRECTORY_SEPARATOR.'toto'
4043
)),
4144
array(array('fo'), array(
45+
$tmpDir.DIRECTORY_SEPARATOR.'.bar',
46+
$tmpDir.DIRECTORY_SEPARATOR.'.foo',
47+
$tmpDir.DIRECTORY_SEPARATOR.'.foo'.DIRECTORY_SEPARATOR.'.bar',
4248
$tmpDir.DIRECTORY_SEPARATOR.'.git',
4349
$tmpDir.DIRECTORY_SEPARATOR.'test.py',
4450
$tmpDir.DIRECTORY_SEPARATOR.'foo',

src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function testAccept($mode, $expected)
3030
public function getAcceptData()
3131
{
3232
return array(
33-
array(FileTypeFilterIterator::ONLY_FILES, array(sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php')),
34-
array(FileTypeFilterIterator::ONLY_DIRECTORIES, array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/toto')),
33+
array(FileTypeFilterIterator::ONLY_FILES, array(sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/.bar', sys_get_temp_dir().'/symfony2_finder/.foo/.bar')),
34+
array(FileTypeFilterIterator::ONLY_DIRECTORIES, array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/toto', sys_get_temp_dir().'/symfony2_finder/.foo')),
3535
);
3636
}
3737
}

src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ static public function setUpBeforeClass()
2020
$tmpDir = sys_get_temp_dir().'/symfony2_finder';
2121
self::$files = array(
2222
$tmpDir.'/.git/',
23+
$tmpDir.'/.foo/',
24+
$tmpDir.'/.foo/.bar',
25+
$tmpDir.'/.bar',
2326
$tmpDir.'/test.py',
2427
$tmpDir.'/foo/',
2528
$tmpDir.'/foo/bar.tmp',

src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testAccept($size, $expected)
3131
public function getAcceptData()
3232
{
3333
return array(
34-
array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto')),
34+
array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), array(sys_get_temp_dir().'/symfony2_finder/.foo', sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto')),
3535
);
3636
}
3737
}

src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function testAccept($mode, $expected)
4040
public function getAcceptData()
4141
{
4242
return array(
43-
array(SortableIterator::SORT_BY_NAME, array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/toto')),
44-
array(SortableIterator::SORT_BY_TYPE, array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/toto', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/test.py')),
45-
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealpath(), $b->getRealpath()); }, array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/toto')),
43+
array(SortableIterator::SORT_BY_NAME, array(sys_get_temp_dir().'/symfony2_finder/.bar', sys_get_temp_dir().'/symfony2_finder/.foo', sys_get_temp_dir().'/symfony2_finder/.foo/.bar', sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/toto')),
44+
array(SortableIterator::SORT_BY_TYPE, array(sys_get_temp_dir().'/symfony2_finder/.foo', sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/toto', sys_get_temp_dir().'/symfony2_finder/.bar', sys_get_temp_dir().'/symfony2_finder/.foo/.bar', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/test.py')),
45+
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealpath(), $b->getRealpath()); }, array(sys_get_temp_dir().'/symfony2_finder/.bar', sys_get_temp_dir().'/symfony2_finder/.foo', sys_get_temp_dir().'/symfony2_finder/.foo/.bar', sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/toto')),
4646
);
4747
}
4848
}

0 commit comments

Comments
 (0)