commit
15face5432
|
@ -101,10 +101,10 @@ class PathRepository extends ArrayRepository
|
|||
{
|
||||
parent::initialize();
|
||||
|
||||
foreach ($this->getPaths() as $path) {
|
||||
$path = realpath($path) . '/';
|
||||
|
||||
foreach ($this->getUrlMatches() as $url) {
|
||||
$path = realpath($url) . '/';
|
||||
$composerFilePath = $path.'composer.json';
|
||||
|
||||
if (!file_exists($composerFilePath)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class PathRepository extends ArrayRepository
|
|||
$package = JsonFile::parseJson($json, $composerFilePath);
|
||||
$package['dist'] = array(
|
||||
'type' => 'path',
|
||||
'url' => $path,
|
||||
'url' => $url,
|
||||
'reference' => '',
|
||||
);
|
||||
|
||||
|
@ -134,11 +134,11 @@ class PathRepository extends ArrayRepository
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a list of all path names matching given url (supports globbing).
|
||||
* Get a list of all (possibly relative) path names matching given url (supports globbing).
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function getPaths()
|
||||
private function getUrlMatches()
|
||||
{
|
||||
return glob($this->url, GLOB_MARK|GLOB_ONLYDIR);
|
||||
}
|
||||
|
|
|
@ -81,4 +81,29 @@ class PathRepositoryTest extends TestCase
|
|||
$package = $packages[1];
|
||||
$this->assertEquals('test/path-unversioned', $package->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify relative repository URLs remain relative, see #4439
|
||||
*/
|
||||
public function testUrlRemainsRelative()
|
||||
{
|
||||
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
|
||||
->getMock();
|
||||
|
||||
$config = new \Composer\Config();
|
||||
$loader = new ArrayLoader(new VersionParser());
|
||||
$versionGuesser = null;
|
||||
|
||||
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', 'with-version'));
|
||||
$relativeUrl = ltrim(substr($repositoryUrl, strlen(getcwd())), DIRECTORY_SEPARATOR);
|
||||
|
||||
$repository = new PathRepository(array('url' => $relativeUrl), $ioInterface, $config, $loader);
|
||||
$packages = $repository->getPackages();
|
||||
|
||||
$this->assertEquals(1, $repository->count());
|
||||
|
||||
$package = $packages[0];
|
||||
$this->assertEquals('test/path-versioned', $package->getName());
|
||||
$this->assertEquals(rtrim($relativeUrl, DIRECTORY_SEPARATOR), rtrim($package->getDistUrl(), DIRECTORY_SEPARATOR));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue