1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-11 01:22:54 +00:00

Fix path repo version parsing to follow COMPOSER_ROOT_VERSION when the git repo is shared with the root package, fixes #6625

This commit is contained in:
Jordi Boggiano 2017-09-11 16:02:48 +02:00
parent f71baa5e0c
commit 1682d7d454

View file

@ -142,6 +142,17 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
);
$package['transport-options'] = $this->options;
// 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'))) {
if (
0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
&& 0 === $this->process->execute('git rev-parse HEAD', $ref2)
&& $ref1 === $ref2
) {
$package['version'] = $rootVersion;
}
}
if (!isset($package['version'])) {
$versionData = $this->versionGuesser->guessVersion($package, $path);
$package['version'] = $versionData['version'] ?: 'dev-master';