git: Re-order methods, move invoke to near the top

This commit is contained in:
Oliver Davies 2020-05-27 09:48:14 +01:00
parent af429a74a4
commit 979aa4a1fc

View file

@ -32,6 +32,19 @@ class ClosesPullRequests
$this->remoteBranch = str_replace('origin/', '', $this->remoteBranch); $this->remoteBranch = str_replace('origin/', '', $this->remoteBranch);
} }
public function __invoke(): void
{
$this->confirmCiStatusIsPassing();
// TODO: Check that the current branch has a tracking branch.
$this->fetchOrigin();
// TODO: Ensure both branches are up to date.
$this->checkoutTargetBranch();
$this->mergeLocalBranch();
$this->pushTargetBranch();
$this->deleteRemoteBranch();
$this->deleteLocalBranch();
}
function confirmCiStatusIsPassing(): void function confirmCiStatusIsPassing(): void
{ {
echo 'Confirming ci-status on PR is green...' . PHP_EOL; echo 'Confirming ci-status on PR is green...' . PHP_EOL;
@ -88,19 +101,6 @@ class ClosesPullRequests
echo 'Deleting local branch...' . PHP_EOL; echo 'Deleting local branch...' . PHP_EOL;
exec(sprintf('git branch -d %s', $this->localBranch)); exec(sprintf('git branch -d %s', $this->localBranch));
} }
public function __invoke(): void
{
$this->confirmCiStatusIsPassing();
// TODO: Check that the current branch has a tracking branch.
$this->fetchOrigin();
// TODO: Ensure both branches are up to date.
$this->checkoutTargetBranch();
$this->mergeLocalBranch();
$this->pushTargetBranch();
$this->deleteRemoteBranch();
$this->deleteLocalBranch();
}
} }
(new ClosesPullRequests())->__invoke(); (new ClosesPullRequests())->__invoke();