예제 #1
0
 /**
  * Initializes path repository.
  *
  * This method will basically read the folder and add the found package.
  */
 protected function initialize()
 {
     parent::initialize();
     foreach ($this->getUrlMatches() as $url) {
         $path = realpath($url) . DIRECTORY_SEPARATOR;
         $composerFilePath = $path . 'composer.json';
         if (!file_exists($composerFilePath)) {
             continue;
         }
         $json = file_get_contents($composerFilePath);
         $package = JsonFile::parseJson($json, $composerFilePath);
         $package['dist'] = array('type' => 'path', 'url' => $url, 'reference' => '');
         if (!isset($package['version'])) {
             $package['version'] = $this->versionGuesser->guessVersion($package, $path) ?: 'dev-master';
         }
         $output = '';
         if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
             $package['dist']['reference'] = trim($output);
         } else {
             $package['dist']['reference'] = Locker::getContentHash($json);
         }
         $package = $this->loader->load($package);
         $this->addPackage($package);
     }
     if (count($this->getPackages()) == 0) {
         throw new \RuntimeException(sprintf('No `composer.json` file found in any path repository in "%s"', $this->url));
     }
 }