Handle "versions" option in PathRepository, remove support for "branch-version"
parent
079e501ac8
commit
725b33ee5a
|
@ -658,6 +658,26 @@ the branch or tag that is currently checked out. Otherwise, the version should
|
|||
be explicitly defined in the package's `composer.json` file. If the version
|
||||
cannot be resolved by these means, it is assumed to be `dev-master`.
|
||||
|
||||
When the version cannot be inferred from the local VCS repository, or when you
|
||||
want to override the version, you can use the `versions` option when declaring
|
||||
the repository:
|
||||
|
||||
```json
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "../../packages/my-package",
|
||||
"options": {
|
||||
"versions": {
|
||||
"my/package": "4.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The local package will be symlinked if possible, in which case the output in
|
||||
the console will read `Symlinking from ../../packages/my-package`. If symlinking
|
||||
is _not_ possible the package will be copied. In that case, the console will
|
||||
|
|
|
@ -164,6 +164,12 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
|
|||
'reference' => sha1($json . serialize($this->options)),
|
||||
);
|
||||
$package['transport-options'] = $this->options;
|
||||
unset($package['transport-options']['versions']);
|
||||
|
||||
// use the version provided as option if available
|
||||
if (isset($package['name'], $this->options['versions'][$package['name']])) {
|
||||
$package['version'] = $this->options['versions'][$package['name']];
|
||||
}
|
||||
|
||||
// carry over the root package version if this path repo is in the same git repository as root package
|
||||
if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
|
||||
|
|
|
@ -97,6 +97,37 @@ class PathRepositoryTest extends TestCase
|
|||
$this->assertEquals(array('test/path-unversioned', 'test/path-versioned'), $names);
|
||||
}
|
||||
|
||||
public function testLoadPackageWithExplicitVersions()
|
||||
{
|
||||
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
|
||||
->getMock();
|
||||
|
||||
$config = new \Composer\Config();
|
||||
$versionGuesser = null;
|
||||
|
||||
$options = array(
|
||||
'versions' => array(
|
||||
'test/path-unversioned' => '4.3.2.1',
|
||||
'test/path-versioned' => '3.2.1.0',
|
||||
),
|
||||
);
|
||||
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', '*'));
|
||||
$repository = new PathRepository(array('url' => $repositoryUrl, 'options' => $options), $ioInterface, $config);
|
||||
$packages = $repository->getPackages();
|
||||
$versions = array();
|
||||
|
||||
$this->assertEquals(2, $repository->count());
|
||||
|
||||
$package = $packages[0];
|
||||
$versions[$package->getName()] = $package->getVersion();
|
||||
|
||||
$package = $packages[1];
|
||||
$versions[$package->getName()] = $package->getVersion();
|
||||
|
||||
ksort($versions);
|
||||
$this->assertSame(array('test/path-unversioned' => '4.3.2.1', 'test/path-versioned' => '3.2.1.0'), $versions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify relative repository URLs remain relative, see #4439
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue