/**
  * @override \ComponentManager\PackageRepository\PackageRepository
  */
 public function getComponent(ComponentSpecification $componentSpecification)
 {
     /** @var \Github\Api\Repo $api */
     $api = $this->getClient()->api('repo');
     list($user, $repositoryName) = explode('/', $componentSpecification->getExtra('repository'));
     $repository = $api->show($user, $repositoryName);
     $refs = array_merge($api->tags($user, $repositoryName), $api->branches($user, $repositoryName));
     $versions = [];
     foreach ($refs as $ref) {
         $versions[] = new ComponentVersion(null, $ref['name'], null, [new GitComponentSource($repository['clone_url'], $ref['name'])]);
     }
     return new Component($componentSpecification->getName(), $versions, $this);
 }
 /**
  * @override \ComponentManager\PackageRepository\PackageRepository
  */
 public function getComponent(ComponentSpecification $componentSpecification)
 {
     $this->maybeLoadPackageCache();
     $componentName = $componentSpecification->getName();
     if (!property_exists($this->packageCache, $componentName)) {
         throw new InvalidProjectException("No component named \"{$componentName}\"", InvalidProjectException::CODE_MISSING_COMPONENT);
     }
     $package = $this->packageCache->{$componentName};
     $versions = [];
     foreach ($package->versions as $version) {
         $sources = [];
         if ($version->downloadurl) {
             $sources[] = new ZipComponentSource($version->downloadurl, $version->downloadmd5);
         }
         if ($version->vcssystem === 'git') {
             $sources[] = new GitComponentSource($version->vcsrepositoryurl, $version->vcstag);
         }
         $versions[] = new ComponentVersion($version->version, $version->release, $version->maturity, $sources);
     }
     return new Component($package->component, $versions, $this);
 }
 /**
  * @override \ComponentManager\PackageRepository\PackageRepository
  */
 public function getComponent(ComponentSpecification $componentSpecification)
 {
     $this->maybeLoadPackageCache();
     $componentName = $componentSpecification->getName();
     try {
         $packageName = $componentSpecification->getExtra('repository');
     } catch (OutOfBoundsException $e) {
         $packageName = $componentName;
     }
     if (!property_exists($this->packageCache, $packageName)) {
         throw new InvalidProjectException("No component named \"{$componentName}\"; seeking repository \"{$packageName}\"", InvalidProjectException::CODE_MISSING_COMPONENT);
     }
     $package = $this->packageCache->{$packageName};
     /* Unfortunately Stash doesn't allow us to retrieve a list of
      * repositories with branches/tags included, so we'll have to
      * incrementally retrieve them for each component as they're
      * requested. */
     $packageCacheDirty = false;
     if (!property_exists($package, 'branches')) {
         $path = $this->getRepositoryBranchesPath($packageName);
         $this->packageCache->{$packageName}->branches = $this->getAllPages($path);
         $packageCacheDirty = true;
     }
     if (!property_exists($package, 'tags')) {
         $path = $this->getRepositoryTagsPath($packageName);
         $this->packageCache->{$packageName}->tags = $this->getAllPages($path);
         $packageCacheDirty = true;
     }
     if ($packageCacheDirty) {
         // TODO: we should probably be logging writes here
         $this->writeMetadataCache($this->packageCache);
     }
     $versions = [];
     /* TODO: For the time being, we'll do these first so that tags take
      *       precedence over branches later when we attempt to satisfy
      *       version specifications. We should definitely be seeking to
      *       replace this crude approach with an indication of priority on
      *       source or version objects later. */
     foreach ($package->tags as $tag) {
         $sources = [];
         foreach ($package->links->clone as $cloneSource) {
             if ($this->shouldAddComponentSource($cloneSource)) {
                 $sources[$cloneSource->name] = new GitComponentSource($cloneSource->href, $tag->displayId);
             }
         }
         $sources = $this->sortComponentSources($sources);
         $versions[] = new ComponentVersion(null, $tag->displayId, null, $sources);
     }
     foreach ($package->branches as $branch) {
         $sources = [];
         foreach ($package->links->clone as $cloneSource) {
             if ($this->shouldAddComponentSource($cloneSource)) {
                 $sources[$cloneSource->name] = new GitComponentSource($cloneSource->href, $branch->displayId);
             }
         }
         $sources = $this->sortComponentSources($sources);
         $versions[] = new ComponentVersion(null, $branch->displayId, null, $sources);
     }
     return new Component($componentName, $versions, $this);
 }
 /**
  * @override \ComponentManager\PackageRepository\PackageRepository
  */
 public function getComponent(ComponentSpecification $componentSpecification)
 {
     return new Component($componentSpecification->getName(), [new ComponentVersion(null, null, null, [new DirectoryComponentSource($componentSpecification->getExtra('directory'))])], $this);
 }