From 87d5b689b2da20d8be5ee1f4bf8ab4261a84eda1 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 23 May 2020 00:05:24 +0100 Subject: [PATCH] git: Refactor to a lookup table --- bin/git-close-pull-request | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/git-close-pull-request b/bin/git-close-pull-request index 39b6ae1..7439342 100755 --- a/bin/git-close-pull-request +++ b/bin/git-close-pull-request @@ -36,9 +36,12 @@ class ClosesPullRequests echo 'Confirming ci-status on PR is green...' . PHP_EOL; // TODO: Check for failures, or skip if there is no CI. - switch (exec('hub ci-status')) { - case self::CI_PENDING: - die('Aborting: CI pending'); + $errors = [ + self::CI_PENDING => 'Aborting: CI pending', + ]; + + if (array_key_exists($status = exec('hub ci-status'), $errors)) { + die($errors[$status]); } }