Пример #1
0
 private function guessHgVersion(array $config)
 {
     if (0 === $this->process->execute('hg branch', $output)) {
         $branch = trim($output);
         $version = $this->versionParser->normalizeBranch($branch);
         $isFeatureBranch = 0 === strpos($version, 'dev-');
         if ('9999999-dev' === $version) {
             $version = 'dev-' . $branch;
         }
         if (!$isFeatureBranch) {
             return $version;
         }
         $config = array('url' => getcwd());
         $driver = new HgDriver($config, new NullIO(), $this->config, $this->process);
         $branches = array_keys($driver->getBranches());
         $version = $this->guessFeatureVersion($config, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"');
         return $version;
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function initialize()
 {
     parent::initialize();
     $cacheUrl = Filesystem::isLocalPath($this->url) ? realpath($this->url) : $this->url;
     $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $cacheUrl));
 }
Пример #3
0
 private function guessHgVersion(array $config)
 {
     // try to fetch current version from hg branch
     if (0 === $this->process->execute('hg branch', $output)) {
         $branch = trim($output);
         $version = $this->versionParser->normalizeBranch($branch);
         $isFeatureBranch = 0 === strpos($version, 'dev-');
         if ('9999999-dev' === $version) {
             $version = 'dev-' . $branch;
         }
         if (!$isFeatureBranch) {
             return $version;
         }
         // re-use the HgDriver to fetch branches (this properly includes bookmarks)
         $config = array('url' => getcwd());
         $driver = new HgDriver($config, new NullIO(), $this->config, $this->process);
         $branches = array_keys($driver->getBranches());
         // try to find the best (nearest) version branch to assume this feature's version
         $version = $this->guessFeatureVersion($config, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"');
         return $version;
     }
 }
Пример #4
0
 /**
  * @dataProvider supportsDataProvider
  */
 public function testSupports($repositoryUrl)
 {
     $this->assertTrue(
         HgDriver::supports($this->io, $this->config, $repositoryUrl)
     );
 }