From ba114c393f91b62fcef820d6ad539cc75076d53a Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Sat, 8 Dec 2018 06:38:22 +0100
Subject: [PATCH] fix(bitbucket): getPrList fetch all

---
 lib/platform/bitbucket/index.js                       | 11 ++++-------
 .../bitbucket/__snapshots__/index.spec.js.snap        |  2 +-
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/platform/bitbucket/index.js b/lib/platform/bitbucket/index.js
index 1a70b78720..17949cd52d 100644
--- a/lib/platform/bitbucket/index.js
+++ b/lib/platform/bitbucket/index.js
@@ -662,16 +662,13 @@ async function getCommitMessages() {
 
 // Pull Request
 
-async function getPrList(state = utils.prStates.open) {
+async function getPrList() {
   logger.debug('getPrList()');
   if (!config.prList) {
     logger.debug('Retrieving PR list');
-    const prs = await utils.accumulateValues(
-      `/2.0/repositories/${config.repository}/pullrequests?state=${state}`,
-      undefined,
-      undefined,
-      50
-    );
+    let url = `/2.0/repositories/${config.repository}/pullrequests?`;
+    url += utils.prStates.all.map(state => 'state=' + state).join('&');
+    const prs = await utils.accumulateValues(url, undefined, undefined, 50);
     config.prList = prs.map(utils.prInfo);
     logger.info({ length: config.prList.length }, 'Retrieved Pull Requests');
   }
diff --git a/test/platform/bitbucket/__snapshots__/index.spec.js.snap b/test/platform/bitbucket/__snapshots__/index.spec.js.snap
index 272e2cf67e..3118dc8b8f 100644
--- a/test/platform/bitbucket/__snapshots__/index.spec.js.snap
+++ b/test/platform/bitbucket/__snapshots__/index.spec.js.snap
@@ -59,7 +59,7 @@ Array [
     "/2.0/repositories/some/empty",
   ],
   Array [
-    "/2.0/repositories/some/empty/pullrequests?state=OPEN&pagelen=50",
+    "/2.0/repositories/some/empty/pullrequests?state=OPEN&state=MERGED&state=DECLINED&state=SUPERSEDED&pagelen=50",
     undefined,
   ],
   Array [
-- 
GitLab