git: Refactor to be based on the gh CLI tool
This commit is contained in:
parent
adac636d47
commit
374f036b79
|
@ -22,10 +22,6 @@ class ClosesPullRequests
|
||||||
private $localBranch;
|
private $localBranch;
|
||||||
private $remoteBranch;
|
private $remoteBranch;
|
||||||
|
|
||||||
private const CI_ERROR = 'error';
|
|
||||||
private const CI_PENDING = 'pending';
|
|
||||||
private const CI_SUCCESS = 'success';
|
|
||||||
|
|
||||||
private const RUN_TYPE_COMMAND = 'command';
|
private const RUN_TYPE_COMMAND = 'command';
|
||||||
private const RUN_TYPE_QUERY = 'query';
|
private const RUN_TYPE_QUERY = 'query';
|
||||||
|
|
||||||
|
@ -89,20 +85,11 @@ class ClosesPullRequests
|
||||||
|
|
||||||
echo 'Confirming ci-status on PR is green...' . PHP_EOL;
|
echo 'Confirming ci-status on PR is green...' . PHP_EOL;
|
||||||
|
|
||||||
// TODO: Check for failures, or skip if there is no CI.
|
$passedCi = $this->run('gh pr checks', self::RUN_TYPE_COMMAND);
|
||||||
$errors = [
|
|
||||||
self::CI_ERROR => 'Aborting: CI error',
|
|
||||||
self::CI_PENDING => 'Aborting: CI pending',
|
|
||||||
];
|
|
||||||
|
|
||||||
$ciStatus = $this->run('hub ci-status', self::RUN_TYPE_QUERY);
|
// TODO: Check if there are no CI checks. Does this return `true` as well?
|
||||||
|
if (!$passedCi) {
|
||||||
switch ($ciStatus) {
|
$this->dieWithMessage('CI pending or failed.');
|
||||||
case self::CI_PENDING:
|
|
||||||
$this->exitWithWarning($errors[$ciStatus]);
|
|
||||||
|
|
||||||
case self::CI_ERROR:
|
|
||||||
$this->dieWithMessage($errors[$ciStatus]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue