merged branch jocl/master (PR #4211)
Commits -------d3fee9b
[Finder] ignoreDotFiles(true) filter does not match (issue #4106) Discussion ---------- Fix for issue #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 intoff7c4757
). --------------------------------------------------------------------------- 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 intoff7c4757
). --------------------------------------------------------------------------- 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) (mergedd3fee9b2
into03d4b026
).
This commit is contained in:
commit
813f6b3bb5
@ -290,7 +290,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
if ($ignoreDotFiles) {
|
||||
$this->ignore = $this->ignore | static::IGNORE_DOT_FILES;
|
||||
} else {
|
||||
$this->ignore = $this->ignore ^ static::IGNORE_DOT_FILES;
|
||||
$this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -312,7 +312,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
if ($ignoreVCS) {
|
||||
$this->ignore = $this->ignore | static::IGNORE_VCS_FILES;
|
||||
} else {
|
||||
$this->ignore = $this->ignore ^ static::IGNORE_VCS_FILES;
|
||||
$this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES;
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -595,7 +595,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
}
|
||||
|
||||
if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
|
||||
$this->exclude[] = '\..+';
|
||||
$this->notNames[] = '/^\..+/';
|
||||
}
|
||||
|
||||
if ($this->exclude) {
|
||||
|
@ -129,23 +129,33 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
public function testIgnoreVCS()
|
||||
{
|
||||
$finder = new Finder();
|
||||
$this->assertSame($finder, $finder->ignoreVCS(false));
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = new Finder();
|
||||
$this->assertSame($finder, $finder->ignoreVCS(true));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = new Finder();
|
||||
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
}
|
||||
|
||||
public function testIgnoreDotFiles()
|
||||
{
|
||||
$finder = new Finder();
|
||||
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
|
||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = new Finder();
|
||||
$this->assertSame($finder, $finder->ignoreDotFiles(true));
|
||||
$this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
}
|
||||
|
||||
public function testSortByName()
|
||||
|
@ -31,9 +31,9 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
public function getAcceptData()
|
||||
{
|
||||
return array(
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -34,11 +34,11 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
public function getAcceptData()
|
||||
{
|
||||
return array(
|
||||
array(array(new NumberComparator('< 1')), array($this->getAbsolutePath('/.git'), $this->getAbsolutePath('/test.py'), $this->getAbsolutePath('/foo'), $this->getAbsolutePath('/test.php'), $this->getAbsolutePath('/toto'))),
|
||||
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'))),
|
||||
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'))),
|
||||
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'))),
|
||||
array(array(new NumberComparator('> 1')), array()),
|
||||
array(array(new NumberComparator('>= 1')), array($this->getAbsolutePath('/foo/bar.tmp'))),
|
||||
array(array(new NumberComparator('1')), array($this->getAbsolutePath('/foo/bar.tmp'))),
|
||||
array(array(new NumberComparator('>= 1')), array($this->getAbsolutePath('/foo/bar.tmp'), $this->getAbsolutePath('/.foo/.bar'))),
|
||||
array(array(new NumberComparator('1')), array($this->getAbsolutePath('/foo/bar.tmp'), $this->getAbsolutePath('/.foo/.bar'))),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,18 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
|
||||
return array(
|
||||
array(array('foo'), array(
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.bar',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.foo',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.foo'.DIRECTORY_SEPARATOR.'.bar',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.git',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'test.py',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'test.php',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'toto'
|
||||
)),
|
||||
array(array('fo'), array(
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.bar',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.foo',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.foo'.DIRECTORY_SEPARATOR.'.bar',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.git',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'test.py',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'foo',
|
||||
|
@ -30,8 +30,8 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
|
||||
public function getAcceptData()
|
||||
{
|
||||
return array(
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ abstract class RealIteratorTestCase extends IteratorTestCase
|
||||
$tmpDir = sys_get_temp_dir().'/symfony2_finder';
|
||||
self::$files = array(
|
||||
$tmpDir.'/.git/',
|
||||
$tmpDir.'/.foo/',
|
||||
$tmpDir.'/.foo/.bar',
|
||||
$tmpDir.'/.bar',
|
||||
$tmpDir.'/test.py',
|
||||
$tmpDir.'/foo/',
|
||||
$tmpDir.'/foo/bar.tmp',
|
||||
|
@ -31,7 +31,7 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
public function getAcceptData()
|
||||
{
|
||||
return array(
|
||||
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')),
|
||||
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')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,9 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
public function getAcceptData()
|
||||
{
|
||||
return array(
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user