diff --git a/bin/git-close-pull-request b/bin/git-close-pull-request index d10f8ea..e9dcc7b 100755 --- a/bin/git-close-pull-request +++ b/bin/git-close-pull-request @@ -32,6 +32,19 @@ class ClosesPullRequests $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 { echo 'Confirming ci-status on PR is green...' . PHP_EOL; @@ -88,19 +101,6 @@ class ClosesPullRequests echo 'Deleting local branch...' . PHP_EOL; 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();