/** * Returns the "type" of increment. * * @param Version $higherVersion * @return string|null one of the type constants */ 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; } return null; }
/** * Displays a warning if the composer and vcs versions are out of sync. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @return type */ public function checkVersions(OutputInterface $output) { $composerVersion = $this->composerFile->getCurrentVersion(); $vcsVersion = $this->vcs->getCurrentVersion(); if (!$composerVersion || !$vcsVersion) { return; } if (!Version::eq($vcsVersion, $composerVersion)) { $output->writeln('<error>The composer file version ' . $composerVersion->getVersion() . ' is not the same as the latest VCS version ' . $vcsVersion->getVersion() . '.</error>'); $output->writeln('You should set the composer version manually.'); } }
protected function execute(InputInterface $input, OutputInterface $output) { if (!$this->flow->isInTheFlow()) { throw new Exception('You are not in a git flow release branch (' . $this->vcs->getCurrentBranch() . ').'); } $composerVersion = $this->composerFile->getCurrentVersion(); $branchVersion = $this->flow->getCurrentVersion(); if (!Version::gt($branchVersion, $composerVersion)) { throw new Exception('The git flow version is not greater than the composer version ' . $composerVersion->getVersion()); } $branchType = $this->flow->getBranchType(); if ($branchType != GitFlowBranch::RELEASE) { if ($this->getDialog()->askConfirmation($output, 'Please confirm to finish this hotfix (yes).')) { $this->updateComposerFile($branchVersion); $this->vcs->finishHotfix(); } } else { $difference = $composerVersion->getDifferenceType($branchVersion); if ($this->getDialog()->askConfirmation($output, 'Please confirm to finish this <info>' . $difference . '</info> release (yes).')) { $this->updateComposerFile($branchVersion); $this->vcs->finishRelease(); } } }
/** * @dataProvider getTagData */ public function testIsValid($tag, $result) { $valid = Version::isValid($tag); $this->assertEquals($result, $valid); }
/** * Sets the new version * * @param Version $version */ public function setVersion(Version $version) { $json = $this->getJson(); $json->version = $version->getVersion(); return $this->save($json); }
/** * Remove all invalid tags from a list * * @param string[] * @return string[] */ protected function filtrateList($tags) { $validTags = array(); foreach ($tags as $tag) { if (Version::isValid($tag)) { $validTags[] = $tag; } } return $validTags; }
public function startReleaseCallback(Version $version) { $this->assertEquals('0.2.0', $version->getVersion()); }
public function startHotfixCallback(Version $version) { $this->assertEquals('0.1.3', $version->getVersion()); }