Exemple #1
0
 public function testParse()
 {
     $version = new Version("v1.1.1");
     $this->assertEquals("1.1.1", $version->getValue());
     $version = new Version("v1.1.1-alpha1");
     $this->assertEquals("1.1.1-alpha1", $version->getValue());
 }
Exemple #2
0
 /**
  * Get best version to install
  *
  * @param OutputInterface $output
  * @return string
  * @throws InvalidArgumentException
  */
 protected function getBestVersion(OutputInterface $output)
 {
     $this->log($output, 'Determining best version to install');
     // Find all versions for the given recipe
     $available = Composer::getLibraryVersions($this->getCommandRunner($output), $this->getRecipe());
     // Choose based on available and preference
     $versions = $this->getVersion()->getComposerVersions();
     foreach ($versions as $version) {
         if (in_array($version, $available)) {
             return $version;
         }
     }
     throw new InvalidArgumentException("Could not install project from version " . $this->version->getValue());
 }
Exemple #3
0
 /**
  * Commit changes to git
  *
  * @param OutputInterface $output
  * @param Library $library
  * @param Version $version
  * @param string $path
  */
 public function commitChanges(OutputInterface $output, Library $library, Version $version, $path)
 {
     $repo = $library->getRepository();
     $versionName = $version->getValue();
     $repo->run("add", array($path));
     $status = $repo->run("status");
     if (stripos($status, 'Changes to be committed:')) {
         $repo->run("commit", array("-m", "Added {$versionName} changelog"));
     }
 }
 /**
  * Checkout the given tag for this library
  *
  * @param OutputInterface $output
  * @param Library $library
  * @param Version $version
  */
 protected function checkoutLibrary(OutputInterface $output, Library $library, Version $version)
 {
     $libraryName = $library->getName();
     $tagName = $version->getValue();
     $this->log($output, "Checking out library <info>{$libraryName}</info> at existing tag <info>{$tagName}</info>");
     $library->resetToTag($output, $version);
 }
Exemple #5
0
 /**
  * Get command to suggest to publish this release
  *
  * @param Version $version
  * @param Project $project
  * @return string Command name
  */
 protected function getPublishCommand($version, $project)
 {
     $command = 'cow release:publish ' . $version->getValue() . ' ' . $project->getName();
     switch ($this->output->getVerbosity()) {
         case Output::VERBOSITY_DEBUG:
             $command .= ' -vvv';
             break;
         case Output::VERBOSITY_VERY_VERBOSE:
             $command .= ' -vv';
             break;
         case Output::VERBOSITY_VERBOSE:
             $command .= ' -v';
             break;
     }
     return $command;
 }
Exemple #6
0
 /**
  * Get changelog path
  *
  * @param Version $version
  * @return string
  */
 public function getChangelogPath(Version $version)
 {
     $cowData = $this->getCowData();
     // If generating via markdown committed to source control
     if (empty($cowData['changelog-path'])) {
         return null;
     }
     $path = Format::formatString($cowData['changelog-path'], ['stability' => $version->getStability(), 'stabilityVersion' => $version->getStabilityVersion(), 'major' => $version->getMajor(), 'minor' => $version->getMinor(), 'patch' => $version->getPatch(), 'version' => $version->getValue(), 'versionStable' => $version->getValueStable()]);
     // Collapse duplicate //
     return str_replace('//', '/', $path);
 }