Пример #1
0
 /**
  * Prepares release notes for the requested repository.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input The command input.
  * @param \Symfony\Component\Console\Output\OutputInterface $output The command output.
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $promptFactory = new PromptFactory($input, $output, $this->getHelperSet()->get('question'), $this->getHelperSet()->get('formatter'));
     $client = GithubClient::createWithToken($this->_getToken($input, $promptFactory), $input->getArgument('repo-owner'), $input->getArgument('repo-name'), $input->getOption('github-api'));
     $targetBranch = $input->getOption('target-branch');
     $baseTagName = $this->_getBaseTagName($input, $client, $targetBranch);
     $release = $this->_buildRelease($input, $client, $targetBranch, $baseTagName);
     $defaultChoice = $input->getOption('publish') ? 'p' : 'd';
     $choices = ['b' => 'Change Target Branch', 't' => 'Change Base Tag', 'c' => 'Categorize Changes', 'v' => 'Change Version', 'n' => 'Change Release Name', 'r' => 'Randomize Release Name', 'e' => 'Edit Release Notes', 'd' => 'Submit Draft Release', 'p' => 'Publish Release', 'q' => 'Cancel and Quit'];
     $done = false;
     while (!$done) {
         $choice = $promptFactory->invoke('What would you like to do?', $defaultChoice, $choices, $release->previewFormat());
         $result = $this->_handleUserInput($release, $promptFactory, $client, $input, $choice);
         if ($result === true) {
             $done = true;
         } elseif ($result === false) {
             return;
         } elseif ($result !== null) {
             $release = $result;
         }
     }
     $this->_submitRelease($promptFactory, $client, $release);
 }
Пример #2
0
 /**
  * Prepares release notes for the requested repository.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input The command input.
  * @param \Symfony\Component\Console\Output\OutputInterface $output The command output.
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $promptFactory = new PromptFactory($input, $output, $this->getHelperSet()->get('question'), $this->getHelperSet()->get('formatter'));
     $client = GithubClient::createWithToken($this->_getToken($input, $promptFactory), $input->getArgument('repo-owner'), $input->getArgument('repo-name'), $input->getOption('github-api'));
     $targetBranch = $input->getOption('target-branch');
     $baseTagName = $this->_getBaseTagName($input, $client, $targetBranch);
     $release = $this->_buildRelease($input, $client, $targetBranch, $baseTagName);
     $defaultChoice = $input->getOption('publish') ? 'p' : 'd';
     $choices = ['b' => 'Change Target Branch', 't' => 'Change Base Tag', 'c' => 'Categorize Changes', 'v' => 'Change Version', 'n' => 'Change Release Name', 'r' => 'Randomize Release Name', 'e' => 'Edit Release Notes', 'd' => 'Submit Draft Release', 'p' => 'Publish Release', 'q' => 'Cancel and Quit'];
     $done = false;
     while (!$done) {
         $choice = $promptFactory->invoke('What would you like to do?', $defaultChoice, $choices, $release->previewFormat());
         switch ($choice) {
             case 'b':
                 $targetBranch = $promptFactory->invoke('Please enter the target branch');
                 $baseTagName = $this->_getBaseTagName($input, $client, $targetBranch);
                 $release = $this->_buildRelease($input, $client, $targetBranch, $baseTagName);
                 break;
             case 't':
                 $targetBranch = $release->targetCommitish;
                 $baseTagName = $promptFactory->invoke('Please enter the base tag', $release->currentVersion);
                 $release = $this->_buildRelease($input, $client, $targetBranch, $baseTagName);
                 break;
             case 'c':
                 $selectTypeForChange = function (Change $change) use($promptFactory) {
                     return $promptFactory->invoke('What type of change is this PR?', $change->getType(), $change::types(), $change->displayFull());
                 };
                 $release->changes = $this->_getChangesInRange($client, $release->currentVersion->unprocessed(), $release->targetCommitish, $selectTypeForChange);
                 $release->version = $this->_getVersion($input, $release->currentVersion, $release->changes);
                 $release->notes = $release->changes->display();
                 break;
             case 'v':
                 $suggestedVersions = $this->_getSuggestedNewVersions($release->currentVersion, $release->changes);
                 $currentVersion = $release->currentVersion;
                 $defaultVersion = $release->version;
                 $release->version = new Version($promptFactory->invoke("Version Number (current: {$currentVersion})", $defaultVersion, $suggestedVersions, null, false));
                 break;
             case 'n':
                 $release->name = $promptFactory->invoke('Release Name', $release->name);
                 break;
             case 'r':
                 $randomNameGenerator = new Vgng();
                 $release->name = $randomNameGenerator->getName();
                 break;
             case 'e':
                 $release->notes = $this->_amendReleaseNotes($input, $release->notes);
                 break;
             case 'd':
                 $release->isDraft = true;
                 $done = true;
                 break;
             case 'p':
                 $release->isDraft = false;
                 $done = true;
                 break;
             case 'q':
                 return;
         }
     }
     $this->_submitRelease($promptFactory, $client, $release);
 }