Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

"artifact" type repo creates absolute paths in .lock file #2698

Merged
merged 1 commit into from

2 participants

Matthias Pigulla Jordi Boggiano
Matthias Pigulla

The "artifact" type repository can take a relative path to a directory containing .zip files.

However, the .lock file will contain absolute paths to the installed package .zip files. Obviously that's a problem when someone else tries to install from this lock file with a checkout in another location.

Jordi Boggiano Seldaek added Feature Bug and removed Feature labels
Jordi Boggiano Seldaek added this to the Bugs milestone
Matthias Pigulla

Does it make sense to have an artifacts folder that is not below your root package?

Jordi Boggiano
Owner

@mpdude yes people use network mounts somewhere on their machine containing all the artifacts of their company for example. I don't really know if we can fix this though. Having a relative path to a parent folder would probably not help a lot..

Matthias Pigulla mpdude This should create relative/absolute dist URLs depending on the way (…
…relative/absolute) the artifact directory path was given.
beff1f5
Matthias Pigulla

So what about this...? What am I missing?

Matthias Pigulla

@Seldaek What do you think - does this solve the problem? This would use absolute/relative paths depending on the way the artifact is referenced.

Jordi Boggiano
Owner

I guess it's fine to merge. Thanks and sorry for the delay..

Jordi Boggiano Seldaek merged commit beff1f5 into from
Matthias Pigulla mpdude deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 18, 2014
  1. Matthias Pigulla

    This should create relative/absolute dist URLs depending on the way (…

    mpdude authored
    …relative/absolute) the artifact directory path was given.
This page is out of date. Refresh to see the latest.
2  src/Composer/Repository/ArtifactRepository.php
View
@@ -96,7 +96,7 @@ private function getComposerInformation(\SplFileInfo $file)
$package = JsonFile::parseJson($json, $composerFile);
$package['dist'] = array(
'type' => 'zip',
- 'url' => $file->getRealPath(),
+ 'url' => $file->getPathname(),
'reference' => $file->getBasename(),
'shasum' => sha1_file($file->getRealPath())
);
24 tests/Composer/Test/Repository/ArtifactRepositoryTest.php
View
@@ -16,6 +16,7 @@
use Composer\IO\NullIO;
use Composer\Config;
use Composer\Package\BasePackage;
+use Composer\Util\Filesystem;
class ArtifactRepositoryTest extends TestCase
{
@@ -40,4 +41,27 @@ public function testExtractsConfigsFromZipArchives()
$this->assertSame($expectedPackages, $foundPackages);
}
+
+ public function testAbsoluteRepoUrlCreatesAbsoluteUrlPackages()
+ {
+ $absolutePath = __DIR__ . '/Fixtures/artifacts';
+ $coordinates = array('type' => 'artifact', 'url' => $absolutePath);
+ $repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
+
+ foreach ($repo->getPackages() as $package) {
+ $this->assertTrue(strpos($package->getDistUrl(), $absolutePath) === 0);
+ }
+ }
+
+ public function testRelativeRepoUrlCreatesRelativeUrlPackages()
+ {
+ $relativePath = 'tests/Composer/Test/Repository/Fixtures/artifacts';
+ $coordinates = array('type' => 'artifact', 'url' => $relativePath);
+ $repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
+
+ foreach ($repo->getPackages() as $package) {
+ $this->assertTrue(strpos($package->getDistUrl(), $relativePath) === 0);
+ }
+ }
+
}
Something went wrong with that request. Please try again.