Moved file back to correct location. (+1 squashed commit)
Squashed commits: [eec32aa] Updated detection to only allow composer.josn in root or first level dir.pull/2188/head
parent
bc76e0014b
commit
24aba5b51f
|
@ -88,6 +88,18 @@ class ArtifactRepository extends ArrayRepository
|
||||||
for ($i = 0; $i < $zip->numFiles; $i++ ){
|
for ($i = 0; $i < $zip->numFiles; $i++ ){
|
||||||
$stat = $zip->statIndex($i);
|
$stat = $zip->statIndex($i);
|
||||||
if (strcmp(basename($stat['name']), $filename) === 0){
|
if (strcmp(basename($stat['name']), $filename) === 0){
|
||||||
|
$directoryName = dirname($stat['name']);
|
||||||
|
if ($directoryName == '.') {
|
||||||
|
//if composer.json is in root directory
|
||||||
|
//it has to be the one to use.
|
||||||
|
return $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strpos($directoryName, '\\') !== false ||
|
||||||
|
strpos($directoryName, '/') !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$length = strlen($stat['name']);
|
$length = strlen($stat['name']);
|
||||||
if ($indexOfShortestMatch == false || $length < $lengthOfShortestMatch) {
|
if ($indexOfShortestMatch == false || $length < $lengthOfShortestMatch) {
|
||||||
//Check it's not a directory.
|
//Check it's not a directory.
|
||||||
|
|
|
@ -27,10 +27,12 @@ class ArtifactRepositoryTest extends TestCase
|
||||||
'vendor1/package2-4.3.2',
|
'vendor1/package2-4.3.2',
|
||||||
'vendor3/package1-5.4.3',
|
'vendor3/package1-5.4.3',
|
||||||
'test/jsonInRoot-1.0.0',
|
'test/jsonInRoot-1.0.0',
|
||||||
'test/jsonInFirstLevel-1.0.0'
|
'test/jsonInFirstLevel-1.0.0',
|
||||||
|
//The files not-an-artifact.zip and jsonSecondLevel are not valid
|
||||||
|
//artifacts and do not get detected.
|
||||||
);
|
);
|
||||||
|
|
||||||
$coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts/correct');
|
$coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts');
|
||||||
$repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
|
$repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
|
||||||
|
|
||||||
$foundPackages = array_map(function(BasePackage $package) {
|
$foundPackages = array_map(function(BasePackage $package) {
|
||||||
|
@ -42,14 +44,6 @@ class ArtifactRepositoryTest extends TestCase
|
||||||
|
|
||||||
$this->assertSame($expectedPackages, $foundPackages);
|
$this->assertSame($expectedPackages, $foundPackages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtractConfigFails()
|
|
||||||
{
|
|
||||||
$this->setExpectedException('RuntimeException', "Shouldn't have picked up composer.json from a location other than root or first level directory.");
|
|
||||||
|
|
||||||
$coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts/error/jsonWrongDirectory');
|
|
||||||
new ArtifactRepository($coordinates, new NullIO(), new Config());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//$archivesToCreate = array(
|
//$archivesToCreate = array(
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue