Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4: (22 commits)
  fix merge
  [AssetMapper] Check asset/vendor directory is writable
  detect wrong e-mail validation modes
  detect wrong usages of minMessage/maxMessage in options
  [Security] Remove workflow from empty folder
  read form values using the chain data accessor
  [Validator] Review Bulgarian (bg) translation
  Reviewed italian translation
  Fix french translation
  call substr() with integer offsets
  [Finder] Also consider .git inside the basedir of in() directory
  review: FR translation
  [Serializer] Add AbstractNormalizerContextBuilder::defaultConstructorArguments()
  Update spanish and catalan translations
  Update AbstractSchemaListener.php to adjust more database params
  Updated id=113 Arabic translation.
  #53771 Updated validator Lithuanian translations
  review: translation RU
  [PropertyInfo] Fix PHPStan properties type in trait
  explicitly cast boolean SSL stream options
  ...
  • Loading branch information
xabbuh committed Apr 28, 2024
2 parents 337e3a6 + 511c489 commit 4d58f0f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Iterator/VcsIgnoredFilterIterator.php
Expand Up @@ -37,9 +37,9 @@ public function __construct(\Iterator $iterator, string $baseDir)
{
$this->baseDir = $this->normalizePath($baseDir);

foreach ($this->parentDirectoriesUpwards($this->baseDir) as $parentDirectory) {
if (@is_dir("{$parentDirectory}/.git")) {
$this->baseDir = $parentDirectory;
foreach ([$this->baseDir, ...$this->parentDirectoriesUpwards($this->baseDir)] as $directory) {
if (@is_dir("{$directory}/.git")) {
$this->baseDir = $directory;
break;
}
}
Expand Down
54 changes: 52 additions & 2 deletions Tests/Iterator/VcsIgnoredFilterIteratorTest.php
Expand Up @@ -34,7 +34,7 @@ protected function tearDown(): void
*
* @dataProvider getAcceptData
*/
public function testAccept(array $gitIgnoreFiles, array $otherFileNames, array $expectedResult)
public function testAccept(array $gitIgnoreFiles, array $otherFileNames, array $expectedResult, string $baseDir = '')
{
$otherFileNames = $this->toAbsolute($otherFileNames);
foreach ($otherFileNames as $path) {
Expand All @@ -51,7 +51,8 @@ public function testAccept(array $gitIgnoreFiles, array $otherFileNames, array $

$inner = new InnerNameIterator($otherFileNames);

$iterator = new VcsIgnoredFilterIterator($inner, $this->tmpDir);
$baseDir = $this->tmpDir.('' !== $baseDir ? '/'.$baseDir : '');
$iterator = new VcsIgnoredFilterIterator($inner, $baseDir);

$this->assertIterator($this->toAbsolute($expectedResult), $iterator);
}
Expand All @@ -74,6 +75,55 @@ public static function getAcceptData(): iterable
],
];

yield 'simple file - .gitignore and in() from repository root' => [
[
'.gitignore' => 'a.txt',
],
[
'.git',
'a.txt',
'b.txt',
'dir/',
'dir/a.txt',
],
[
'.git',
'b.txt',
'dir',
],
];

yield 'nested git repositories only consider .gitignore files of the most inner repository' => [
[
'.gitignore' => "nested/*\na.txt",
'nested/.gitignore' => 'c.txt',
'nested/dir/.gitignore' => 'f.txt',
],
[
'.git',
'a.txt',
'b.txt',
'nested/',
'nested/.git',
'nested/c.txt',
'nested/d.txt',
'nested/dir/',
'nested/dir/e.txt',
'nested/dir/f.txt',
],
[
'.git',
'a.txt',
'b.txt',
'nested',
'nested/.git',
'nested/d.txt',
'nested/dir',
'nested/dir/e.txt',
],
'nested',
];

yield 'simple file at root' => [
[
'.gitignore' => '/a.txt',
Expand Down

0 comments on commit 4d58f0f

Please sign in to comment.