From a1c3231a48a8b41febd352835f8bb4d7d7efb1d6 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Wed, 27 May 2020 10:53:33 +0100
Subject: [PATCH] git: Allow for setting the target branch

---
 bin/git-close-pull-request | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bin/git-close-pull-request b/bin/git-close-pull-request
index e9dcc7b6..03e1d02f 100755
--- a/bin/git-close-pull-request
+++ b/bin/git-close-pull-request
@@ -16,7 +16,7 @@
 
 class ClosesPullRequests
 {
-    private $targetBranch = 'master';
+    private $targetBranch;
     private $localBranch;
     private $remoteBranch;
 
@@ -28,6 +28,11 @@ class ClosesPullRequests
     {
         $this->localBranch = exec('git rev-parse --abbrev-ref HEAD');
 
+        $this->targetBranch = getenv('TARGET_BRANCH');
+        if (!$this->targetBranch) {
+            die('No target branch specified. Aborting.');
+        }
+
         $this->remoteBranch = exec('git rev-parse --abbrev-ref --symbolic-full-name @{u}');
         $this->remoteBranch = str_replace('origin/', '', $this->remoteBranch);
     }