Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pr = $this->getAdapter()->getPullRequest($input->getArgument('pr_number'));
     $sourceOrg = $pr['head']['user'];
     $branchName = $pr['head']['ref'];
     /** @var GitConfigHelper $gitConfigHelper */
     $gitConfigHelper = $this->getHelper('git_config');
     $gitConfigHelper->ensureRemoteExists($sourceOrg, $pr['head']['repo']);
     /** @var GitHelper $gitHelper */
     $gitHelper = $this->getHelper('git');
     $gitHelper->remoteUpdate($sourceOrg);
     $lastTag = $gitHelper->getLastTagOnBranch($sourceOrg . '/' . $branchName);
     if (empty($lastTag)) {
         $lastTag = '0.0.0';
     }
     // adjust case for format v2.3
     $lastTag = ltrim($lastTag, 'v');
     $builder = Parser::toBuilder($lastTag);
     switch (true) {
         case $input->getOption('major'):
             $builder->incrementMajor();
             break;
         case $input->getOption('minor'):
             $builder->incrementMinor();
             break;
         case $input->getOption('patch'):
             $builder->incrementPatch();
             break;
         default:
             $builder->incrementPatch();
             break;
     }
     $output->writeln(Dumper::toString($builder->getVersion()));
     return self::COMMAND_SUCCESS;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function run(OutputInterface $output)
 {
     $baseBranch = $this->getParameter('base_branch');
     $release = $this->getParameter('release');
     $this->runGit($output, ['git', 'checkout', $baseBranch]);
     $lastTag = $this->runCommand(['git', 'describe', '--tags', '--abbrev=0', 'HEAD']);
     $builder = Parser::toBuilder($lastTag);
     switch (true) {
         case 'major' === $release:
             $builder->incrementMajor();
             break;
         case 'minor' === $release:
             $builder->incrementMinor();
             break;
         case 'patch' === $release:
             $builder->incrementPatch();
             break;
         default:
             $builder->incrementPatch();
             break;
     }
     $newNumber = Dumper::toString($builder->getVersion());
     $this->runGit($output, ['git', 'tag', '-a', $newNumber, '-m', 'auto tagged']);
     $this->runGit($output, ['git', 'push', '--tags']);
 }
Ejemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('filename');
     $versionNumber = file_get_contents($filename);
     $version = Builder::create()->importString($versionNumber);
     $part = $input->getOption('part');
     switch (strtolower($part)) {
         case self::PART_MAJOR:
             $version->incrementMajor();
             $version->clearPreRelease();
             $version->clearBuild();
             break;
         case self::PART_PATCH:
             $version->incrementPatch();
             $version->clearPreRelease();
             $version->clearBuild();
             break;
         case self::PART_MINOR:
             $version->incrementMinor();
             $version->clearPreRelease();
             $version->clearBuild();
             break;
         default:
             throw new \InvalidArgumentException('Invalid name for the version part was provided, received: ' . $part);
             break;
     }
     $preRelease = $input->getOption('pre-release');
     if ($preRelease) {
         $version->setPreRelease(array($preRelease));
     }
     $newVersionNumber = Dumper::toString($version);
     file_put_contents($filename, $newVersionNumber);
     $output->writeln("<info>The version number was incremented from <comment>{$versionNumber}</comment> to " . "<comment>{$newVersionNumber}</comment></info>");
 }
 public function testIncrementVersion()
 {
     $newVersion = (new Builder())->importString('1.2.4');
     $this->assertNotSame($this->versioner->getCurrentVersion(), Dumper::toString($newVersion));
     $this->commitAChange();
     $this->assertSame(Dumper::toString($newVersion), $this->versioner->incrementVersion('Patch'));
 }
Ejemplo n.º 5
0
 // Retrieve manifest
 echo " - Downloading manifest...{$n}";
 $manifest = file_get_contents('http://box-project.github.io/box2/manifest.json');
 echo " - Reading manifest...{$n}";
 $manifest = json_decode($manifest);
 $current = null;
 foreach ($manifest as $item) {
     $item->version = Parser::toVersion($item->version);
     if ($current && Comparator::isGreaterThan($item->version, $current->version)) {
         $current = $item;
     }
 }
 if (!$item) {
     echo " x No application download was found.{$n}";
 }
 echo " - Downloading Box v", Dumper::toString($item->version), "...{$n}";
 file_put_contents($item->name, file_get_contents($item->url));
 echo " - Checking file checksum...{$n}";
 if ($item->sha1 !== sha1_file($item->name)) {
     unlink($item->name);
     echo " x The download was corrupted.{$n}";
 }
 echo " - Checking if valid Phar...{$n}";
 try {
     new Phar($item->name);
 } catch (Exception $e) {
     echo " x The Phar is not valid.\n\n";
     throw $e;
 }
 echo " - Making Box executable...{$n}";
 @chmod($item->name, 0755);
Ejemplo n.º 6
0
 public function testToString()
 {
     $this->assertEquals('1.2.3-pre.1+build.1', Dumper::toString($this->version));
 }
Ejemplo n.º 7
0
 /**
  * Increment the patch version
  *
  * @param string $version
  * @return string
  */
 private function incrementVersion($version)
 {
     $builder = Version\Parser::toBuilder($version);
     $builder->incrementPatch();
     return Version\Dumper::toString($builder->getVersion());
 }
Ejemplo n.º 8
0
 private function setVersion(Version $version)
 {
     return (new Builder())->importString($this->vcs->setVersion(Dumper::toString($version)));
 }
Ejemplo n.º 9
0
 /**
  *
  */
 public function testAddedPublicMethodInInterface()
 {
     $this->assertEquals('2.0.0', Dumper::toString($this->core->runInspection($this->basePath . 'Interfaces' . DIRECTORY_SEPARATOR . 'AddedPublicMethod.php')));
 }
Ejemplo n.º 10
0
 /**
  * @param Version $version
  * @param $file
  * @param $param
  * @throws \RuntimeException
  */
 protected function updateParametersFile(Version $version, $file, $param)
 {
     $yamlParser = new Parser();
     $params = $yamlParser->parse(file_get_contents($file));
     if (!empty($params['parameters'])) {
         $params['parameters'][$param] = Dumper::toString($version);
         file_put_contents($file, Yaml::dump($params));
     } else {
         throw new \RuntimeException('Not valid parameters file?');
     }
 }