Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Show merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 15, 2021
1 parent 7bc7cb3 commit 363f9ae
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Command/MergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -102,22 +103,28 @@ protected function execute(InputInterface $input, OutputInterface $output): int
]);

foreach ($pullRequests as $pullRequest) {
$status = '<fg=red>ERROR</>';
$status = '<fg=red>UNSTABLE</>';

if ($pullRequest->updatedWithinTheLast60Seconds()) {
$status = '<fg=yellow>SKIPPED</>';
} elseif (true === $pullRequest->isMergeable() && $pullRequest->isCleanBuild()) {
if ($config->isDryRun()) {
$io->write('<fg=yellow>READY</> ');
} else {
$this->pullRequests->merge($repository, $pullRequest, $config->isSquash());
$this->pullRequests->removeLabel($repository, $pullRequest, $label);

if ($config->isSquash()) {
$status = '<fg=green>SQUASHED</>';
} else {
$status = '<fg=green>MERGED</>';
}

try {
$this->pullRequests->merge($repository, $pullRequest, $config->isSquash());
$this->pullRequests->removeLabel($repository, $pullRequest, $label);
} catch (RuntimeException $exception) {
$status = '<fg=red>ERROR</>';

$io->error($exception->getMessage());
}
}
}

Expand Down

0 comments on commit 363f9ae

Please sign in to comment.