示例#1
0
 /**
  * Returns the "type" of increment.
  * 
  * @param Version $higherVersion
  */
 public function getDifferenceType(Version $higherVersion)
 {
     if ($higherVersion->getMajor() > $this->getMajor()) {
         return self::TYPE_MAJOR;
     }
     if ($higherVersion->getMinor() > $this->getMinor()) {
         return self::TYPE_MINOR;
     }
     if ($higherVersion->getPatch() > $this->getPatch()) {
         return self::TYPE_PATCH;
     }
     if ($higherVersion->getBuild() > $this->getBuild()) {
         return self::TYPE_BUILD;
     }
     return null;
 }
示例#2
0
 /**
  * Returns the highest valid version tag.
  * 
  * @return Version
  */
 public function getCurrentVersion()
 {
     $tags = $this->getValidVersionTags();
     if (count($tags) === 0) {
         return Version::createInitialVersion();
     }
     usort($tags, array("vierbergenlars\\SemVer\\version", "compare"));
     return new Version(array_pop($tags));
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->getContext()->setService('output', $this->output);
     $this->getContext()->getInformationCollector()->handleCommandInput($input);
     // Get the current version or generate a new one if the user has confirm that this is required
     try {
         $currentVersion = $this->getContext()->getVersionPersister()->getCurrentVersion();
     } catch (\Liip\RMT\Exception\NoReleaseFoundException $e) {
         if ($this->getContext()->getInformationCollector()->getValueFor('confirm-first') == false) {
             throw $e;
         }
         $currentVersion = \Liip\RMT\Version::createInitialVersion();
     }
     $this->getContext()->setParameter('current-version', $currentVersion);
     $this->writeBigTitle('New release (current is ' . $currentVersion . ')');
     $this->executeActionListIfExist('prerequisites');
 }
示例#4
0
 /**
  * @dataProvider versionProvider
  */
 public function testGetDifferenceType(Version $higherVersion, $expected)
 {
     $version = new Version('1.0.0');
     $result = $version->getDifferenceType($higherVersion);
     $this->assertEquals($expected, $result);
 }
 /**
  * Returns 0.0.0
  * 
  * @return vierbergenlars\SemVer\version
  */
 public function getInitialVersion()
 {
     return Version::createInitialVersion();
 }