diff --git a/src/Command/MergeCommand.php b/src/Command/MergeCommand.php index a7630fc..163a51c 100644 --- a/src/Command/MergeCommand.php +++ b/src/Command/MergeCommand.php @@ -11,6 +11,7 @@ namespace Nucleos\AutoMergeAction\Command; +use Github\Exception\RuntimeException; use Nucleos\AutoMergeAction\Client\PullRequest\Query; use Nucleos\AutoMergeAction\Client\PullRequests; use Nucleos\AutoMergeAction\Config\Configuration; @@ -102,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ]); foreach ($pullRequests as $pullRequest) { - $status = 'ERROR'; + $status = 'UNSTABLE'; if ($pullRequest->updatedWithinTheLast60Seconds()) { $status = 'SKIPPED'; @@ -110,14 +111,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($config->isDryRun()) { $io->write('READY '); } else { - $this->pullRequests->merge($repository, $pullRequest, $config->isSquash()); - $this->pullRequests->removeLabel($repository, $pullRequest, $label); - if ($config->isSquash()) { $status = 'SQUASHED'; } else { $status = 'MERGED'; } + + try { + $this->pullRequests->merge($repository, $pullRequest, $config->isSquash()); + $this->pullRequests->removeLabel($repository, $pullRequest, $label); + } catch (RuntimeException $exception) { + $status = 'ERROR'; + + $io->error($exception->getMessage()); + } } }