Esempio n. 1
0
 private function guessSvnVersion(array $packageConfig, $path)
 {
     SvnUtil::cleanEnv();
     // try to fetch current version from svn
     if (0 === $this->process->execute('svn info --xml', $output, $path)) {
         $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
         $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
         $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
         $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
         if (preg_match($urlPattern, $output, $matches)) {
             if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
                 // we are in a branches path
                 $version = $this->versionParser->normalizeBranch($matches[3]);
                 $prettyVersion = 'dev-' . $matches[3];
                 if ('9999999-dev' === $version) {
                     $version = $prettyVersion;
                 }
                 return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
             }
             $prettyVersion = trim($matches[1]);
             $version = $this->versionParser->normalize($prettyVersion);
             return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
         }
     }
 }
Esempio n. 2
0
 private function validateBranch($branch)
 {
     try {
         return $this->versionParser->normalizeBranch($branch);
     } catch (Exception $e) {
     }
     return false;
 }