/** * Include the package in the alias package if the branch is a root branch * identifier and having a package version. * * @param VcsDriverInterface $driver The vcs driver * @param PackageInterface $package The package instance * @param string $branch The branch name * * @return PackageInterface|AliasPackage */ protected function includeBranchAlias(VcsDriverInterface $driver, PackageInterface $package, $branch) { if (null !== $this->rootPackageVersion && $branch === $driver->getRootIdentifier()) { $aliasNormalized = $this->normalizeBranchAlias($package); $package = $package instanceof AliasPackage ? $package->getAliasOf() : $package; $package = $this->overrideBranchAliasConfig($package, $aliasNormalized, $branch); $package = $this->addPackageAliases($package, $aliasNormalized); } return $package; }
/** * Initializes the root identifier. * * @param VcsDriverInterface $driver */ protected function initRootIdentifier(VcsDriverInterface $driver) { try { if ($driver->hasComposerFile($driver->getRootIdentifier())) { $data = $driver->getComposerInformation($driver->getRootIdentifier()); $sc = new SemverConverter(); $this->rootPackageVersion = !empty($data['version']) ? $sc->convertVersion(ltrim($data['version'], '^~')) : null; $this->rootData = $data; if (null === $this->packageName) { $this->packageName = !empty($data['name']) ? $data['name'] : null; } } } catch (\Exception $e) { if ($this->verbose) { $this->io->write('<error>Skipped parsing ' . $driver->getRootIdentifier() . ', ' . $e->getMessage() . '</error>'); } } }
/** * Include the package in the alias package if the branch is a root branch * identifier and having a package version. * * @param VcsDriverInterface $driver The vcs driver * @param CompletePackageInterface $package The package instance * @param string $branch The branch name * * @return CompletePackageInterface|AliasPackage */ protected function includeBranchAlias(VcsDriverInterface $driver, CompletePackageInterface $package, $branch) { if (null !== $this->rootPackageVersion && $branch === $driver->getRootIdentifier()) { $aliasNormalized = $this->normalizeBranchAlias($package); $package = new AliasPackage($package, $aliasNormalized, $this->rootPackageVersion); } return $package; }