From 788d96e5e9ca4d09d6b59d0a9d3437f94abd960b Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 14 Sep 2018 20:02:51 +0200
Subject: [PATCH] refactor: rename isUnmergeable to isConflicted

---
 lib/platform/bitbucket/index.js                    |  2 +-
 lib/platform/github/index.js                       |  6 +++---
 lib/platform/gitlab/index.js                       |  4 ++--
 lib/platform/vsts/vsts-helper.js                   |  2 +-
 lib/workers/branch/parent.js                       |  4 ++--
 lib/workers/pr/index.js                            |  4 ++--
 lib/workers/repository/finalise/prune.js           |  4 ++--
 lib/workers/repository/onboarding/pr/index.js      |  2 +-
 .../bitbucket/__snapshots__/index.spec.js.snap     |  4 ++--
 .../github/__snapshots__/index.spec.js.snap        | 14 +++++++-------
 .../gitlab/__snapshots__/index.spec.js.snap        |  4 ++--
 .../vsts/__snapshots__/vsts-helper.spec.js.snap    |  4 ++--
 test/platform/vsts/vsts-helper.spec.js             |  2 +-
 test/workers/branch/parent.spec.js                 | 12 ++++++------
 test/workers/pr/index.spec.js                      |  2 +-
 test/workers/repository/finalise/prune.spec.js     |  2 +-
 .../workers/repository/onboarding/pr/index.spec.js |  2 +-
 17 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/lib/platform/bitbucket/index.js b/lib/platform/bitbucket/index.js
index 333f41da9d..0b649888d6 100644
--- a/lib/platform/bitbucket/index.js
+++ b/lib/platform/bitbucket/index.js
@@ -419,7 +419,7 @@ async function getPr(prNo) {
   };
 
   if (utils.prStates.open.includes(pr.state)) {
-    res.isUnmergeable = await isPrConflicted(prNo);
+    res.isConflicted = await isPrConflicted(prNo);
     const commits = await utils.accumulateValues(pr.links.commits.href);
     if (commits.length === 1) {
       res.canRebase = true;
diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js
index ab5bd1fc30..536fa8e84a 100644
--- a/lib/platform/github/index.js
+++ b/lib/platform/github/index.js
@@ -934,9 +934,9 @@ async function getOpenPrs() {
         }
         // https://developer.github.com/v4/enum/mergestatestatus
         if (pr.mergeStateStatus === 'DIRTY') {
-          pr.isUnmergeable = true;
+          pr.isConflicted = true;
         } else {
-          pr.isUnmergeable = false;
+          pr.isConflicted = false;
         }
         if (pr.commits.nodes.length === 1) {
           if (config.gitAuthor) {
@@ -1092,7 +1092,7 @@ async function getPr(prNo) {
     }
     if (pr.mergeable_state === 'dirty') {
       logger.debug({ prNo }, 'PR state is dirty so unmergeable');
-      pr.isUnmergeable = true;
+      pr.isConflicted = true;
     }
     if (pr.commits === 1) {
       if (config.gitAuthor) {
diff --git a/lib/platform/gitlab/index.js b/lib/platform/gitlab/index.js
index ecb55aaa01..63efaf6554 100644
--- a/lib/platform/gitlab/index.js
+++ b/lib/platform/gitlab/index.js
@@ -661,7 +661,7 @@ async function getPr(iid) {
   if (pr.merge_status === 'cannot_be_merged') {
     logger.debug('pr cannot be merged');
     pr.canMerge = false;
-    pr.isUnmergeable = true;
+    pr.isConflicted = true;
   } else {
     // Actually.. we can't be sure
     pr.canMerge = true;
@@ -682,7 +682,7 @@ async function getPr(iid) {
     }
   } catch (err) {
     logger.warn({ err }, 'Error getting PR branch');
-    pr.isUnmergeable = true;
+    pr.isConflicted = true;
   }
   return pr;
 }
diff --git a/lib/platform/vsts/vsts-helper.js b/lib/platform/vsts/vsts-helper.js
index 8a05f82803..1af0b433b3 100644
--- a/lib/platform/vsts/vsts-helper.js
+++ b/lib/platform/vsts/vsts-helper.js
@@ -240,7 +240,7 @@ function getRenovatePRFormat(vstsPr) {
   //   Failure = 5,
   // }
   if (vstsPr.mergeStatus === 2) {
-    pr.isUnmergeable = true;
+    pr.isConflicted = true;
   }
 
   pr.canRebase = true;
diff --git a/lib/workers/branch/parent.js b/lib/workers/branch/parent.js
index 7ad9c5ce7c..acde9ae779 100644
--- a/lib/workers/branch/parent.js
+++ b/lib/workers/branch/parent.js
@@ -40,8 +40,8 @@ async function getParentBranch(config) {
   }
 
   // Now check if PR is unmergeable. If so then we also rebase
-  if (pr && pr.isUnmergeable) {
-    logger.debug('PR is unmergeable');
+  if (pr && pr.isConflicted) {
+    logger.debug('PR is conflicted');
     if (pr.canRebase) {
       logger.info(`Branch is not mergeable and needs rebasing`);
       // TODO: Move this down to api library
diff --git a/lib/workers/pr/index.js b/lib/workers/pr/index.js
index 0d29079279..f9d7124b0d 100644
--- a/lib/workers/pr/index.js
+++ b/lib/workers/pr/index.js
@@ -380,8 +380,8 @@ async function checkAutoMerge(pr, config) {
   if (automerge) {
     logger.debug('PR is configured for automerge');
     // Return if PR not ready for automerge
-    if (pr.isUnmergeable) {
-      logger.info('PR is not mergeable');
+    if (pr.isConflicted) {
+      logger.info('PR is conflicted');
       logger.debug({ pr });
       return false;
     }
diff --git a/lib/workers/repository/finalise/prune.js b/lib/workers/repository/finalise/prune.js
index 496a85ed15..591261ef82 100644
--- a/lib/workers/repository/finalise/prune.js
+++ b/lib/workers/repository/finalise/prune.js
@@ -24,8 +24,8 @@ async function pruneStaleBranches(config, branchList) {
   if (renovateBranches.includes(lockFileBranch)) {
     logger.debug('Checking lock file branch');
     const pr = await platform.getBranchPr(lockFileBranch);
-    if (pr && pr.isUnmergeable) {
-      logger.info('Deleting lock file maintenance branch as it is unmergeable');
+    if (pr && pr.isConflicted) {
+      logger.info('Deleting lock file maintenance branch as it is conflicted');
       await platform.deleteBranch(lockFileBranch);
     }
     renovateBranches = renovateBranches.filter(
diff --git a/lib/workers/repository/onboarding/pr/index.js b/lib/workers/repository/onboarding/pr/index.js
index dfc4a6f284..b784eee09f 100644
--- a/lib/workers/repository/onboarding/pr/index.js
+++ b/lib/workers/repository/onboarding/pr/index.js
@@ -53,7 +53,7 @@ Also, you can post questions about your config in [Renovate's Config Help reposi
   } else {
     configDesc =
       '### Configuration\n\n:abcd: Renovate has detected a custom config for this PR. Feel free to post it to the [Config Help repository](https://github.com/renovatebot/config-help/issues) if you have any doubts and would like it reviewed.\n\n';
-    if (existingPr.isUnmergeable) {
+    if (existingPr.isConflicted) {
       configDesc +=
         ':warning: This PR has a merge conflict, however Renovate is unable to automatically fix that due to edits in this branch. Please resolve the merge conflict manually.\n\n';
     } else {
diff --git a/test/platform/bitbucket/__snapshots__/index.spec.js.snap b/test/platform/bitbucket/__snapshots__/index.spec.js.snap
index 03bb65aab1..1fb0c7cf25 100644
--- a/test/platform/bitbucket/__snapshots__/index.spec.js.snap
+++ b/test/platform/bitbucket/__snapshots__/index.spec.js.snap
@@ -60,8 +60,8 @@ Object {
   "canRebase": true,
   "createdAt": "2018-07-02T07:02:25.275030+00:00",
   "displayNumber": "Pull Request #5",
+  "isConflicted": false,
   "isStale": false,
-  "isUnmergeable": false,
   "number": 5,
   "state": "open",
   "title": "title",
@@ -100,8 +100,8 @@ Object {
   "canRebase": true,
   "createdAt": "2018-07-02T07:02:25.275030+00:00",
   "displayNumber": "Pull Request #5",
+  "isConflicted": false,
   "isStale": false,
-  "isUnmergeable": false,
   "number": 5,
   "state": "open",
   "title": "title",
diff --git a/test/platform/github/__snapshots__/index.spec.js.snap b/test/platform/github/__snapshots__/index.spec.js.snap
index a6686ab1ee..7920ea6181 100644
--- a/test/platform/github/__snapshots__/index.spec.js.snap
+++ b/test/platform/github/__snapshots__/index.spec.js.snap
@@ -305,8 +305,8 @@ Object {
   "canMerge": false,
   "canRebase": true,
   "displayNumber": "Pull Request #2500",
+  "isConflicted": true,
   "isStale": true,
-  "isUnmergeable": true,
   "number": 2500,
   "state": "open",
   "title": "chore(deps): update dependency jest to v23.6.0",
@@ -334,7 +334,7 @@ Object {
   "canRebase": true,
   "commits": 1,
   "displayNumber": "Pull Request #1",
-  "isUnmergeable": true,
+  "isConflicted": true,
   "mergeable_state": "dirty",
   "number": 1,
   "sha": undefined,
@@ -369,7 +369,7 @@ Object {
   "canRebase": false,
   "commits": 1,
   "displayNumber": "Pull Request #1",
-  "isUnmergeable": true,
+  "isConflicted": true,
   "mergeable_state": "dirty",
   "number": 1,
   "sha": undefined,
@@ -386,7 +386,7 @@ Object {
   "canRebase": true,
   "commits": 2,
   "displayNumber": "Pull Request #1",
-  "isUnmergeable": true,
+  "isConflicted": true,
   "mergeable_state": "dirty",
   "number": 1,
   "sha": undefined,
@@ -403,7 +403,7 @@ Object {
   "canRebase": true,
   "commits": 1,
   "displayNumber": "Pull Request #1",
-  "isUnmergeable": true,
+  "isConflicted": true,
   "mergeable_state": "dirty",
   "number": 1,
   "sha": undefined,
@@ -420,7 +420,7 @@ Object {
   "canRebase": true,
   "commits": 2,
   "displayNumber": "Pull Request #1",
-  "isUnmergeable": true,
+  "isConflicted": true,
   "mergeable_state": "dirty",
   "number": 1,
   "sha": undefined,
@@ -436,7 +436,7 @@ Object {
   "branchName": undefined,
   "commits": 2,
   "displayNumber": "Pull Request #1",
-  "isUnmergeable": true,
+  "isConflicted": true,
   "mergeable_state": "dirty",
   "number": 1,
   "sha": undefined,
diff --git a/test/platform/gitlab/__snapshots__/index.spec.js.snap b/test/platform/gitlab/__snapshots__/index.spec.js.snap
index 972298c3ac..da1e9ba0e9 100644
--- a/test/platform/gitlab/__snapshots__/index.spec.js.snap
+++ b/test/platform/gitlab/__snapshots__/index.spec.js.snap
@@ -218,7 +218,7 @@ Object {
   "displayNumber": "Merge Request #12345",
   "id": 1,
   "iid": 12345,
-  "isUnmergeable": true,
+  "isConflicted": true,
   "merge_status": "cannot_be_merged",
   "number": 12345,
   "source_branch": "some-branch",
@@ -235,7 +235,7 @@ Object {
   "displayNumber": "Merge Request #12345",
   "id": 1,
   "iid": 12345,
-  "isUnmergeable": true,
+  "isConflicted": true,
   "merge_status": "cannot_be_merged",
   "number": 12345,
   "source_branch": "some-branch",
diff --git a/test/platform/vsts/__snapshots__/vsts-helper.spec.js.snap b/test/platform/vsts/__snapshots__/vsts-helper.spec.js.snap
index 58ed9f3a1d..df227f3f6d 100644
--- a/test/platform/vsts/__snapshots__/vsts-helper.spec.js.snap
+++ b/test/platform/vsts/__snapshots__/vsts-helper.spec.js.snap
@@ -88,11 +88,11 @@ Object {
 }
 `;
 
-exports[`platform/vsts/helpers getRenovatePRFormat should be formated (isUnmergeable) 1`] = `
+exports[`platform/vsts/helpers getRenovatePRFormat should be formated (isConflicted) 1`] = `
 Object {
   "canRebase": true,
   "displayNumber": "Pull Request #undefined",
-  "isUnmergeable": true,
+  "isConflicted": true,
   "mergeStatus": 2,
   "number": undefined,
   "status": "open",
diff --git a/test/platform/vsts/vsts-helper.spec.js b/test/platform/vsts/vsts-helper.spec.js
index 1aa6848db1..9f8c4c5769 100644
--- a/test/platform/vsts/vsts-helper.spec.js
+++ b/test/platform/vsts/vsts-helper.spec.js
@@ -271,7 +271,7 @@ describe('platform/vsts/helpers', () => {
       expect(res).toMatchSnapshot();
     });
 
-    it('should be formated (isUnmergeable)', () => {
+    it('should be formated (isConflicted)', () => {
       const res = vstsHelper.getRenovatePRFormat({ mergeStatus: 2 });
       expect(res).toMatchSnapshot();
     });
diff --git a/test/workers/branch/parent.spec.js b/test/workers/branch/parent.spec.js
index 707fd884bf..5ab57d862a 100644
--- a/test/workers/branch/parent.spec.js
+++ b/test/workers/branch/parent.spec.js
@@ -26,7 +26,7 @@ describe('workers/branch/parent', () => {
     it('returns branchName if does not need rebaseing', async () => {
       platform.branchExists.mockReturnValue(true);
       platform.getBranchPr.mockReturnValue({
-        isUnmergeable: false,
+        isConflicted: false,
       });
       const res = await getParentBranch(config);
       expect(res.parentBranch).toBe(config.branchName);
@@ -34,7 +34,7 @@ describe('workers/branch/parent', () => {
     it('returns branchName if unmergeable and cannot rebase', async () => {
       platform.branchExists.mockReturnValue(true);
       platform.getBranchPr.mockReturnValue({
-        isUnmergeable: true,
+        isConflicted: true,
         canRebase: false,
       });
       const res = await getParentBranch(config);
@@ -43,7 +43,7 @@ describe('workers/branch/parent', () => {
     it('returns undefined if manual rebase by label', async () => {
       platform.branchExists.mockReturnValue(true);
       platform.getBranchPr.mockReturnValue({
-        isUnmergeable: true,
+        isConflicted: true,
         canRebase: false,
         labels: ['rebase'],
       });
@@ -53,7 +53,7 @@ describe('workers/branch/parent', () => {
     it('returns undefined if unmergeable and can rebase', async () => {
       platform.branchExists.mockReturnValue(true);
       platform.getBranchPr.mockReturnValue({
-        isUnmergeable: true,
+        isConflicted: true,
         canRebase: true,
       });
       const res = await getParentBranch(config);
@@ -63,7 +63,7 @@ describe('workers/branch/parent', () => {
       config.isGitLab = true;
       platform.branchExists.mockReturnValue(true);
       platform.getBranchPr.mockReturnValue({
-        isUnmergeable: true,
+        isConflicted: true,
         canRebase: true,
       });
       const res = await getParentBranch(config);
@@ -90,7 +90,7 @@ describe('workers/branch/parent', () => {
       platform.branchExists.mockReturnValue(true);
       platform.isBranchStale.mockReturnValueOnce(true);
       platform.getBranchPr.mockReturnValue({
-        isUnmergeable: true,
+        isConflicted: true,
         canRebase: false,
       });
       const res = await getParentBranch(config);
diff --git a/test/workers/pr/index.spec.js b/test/workers/pr/index.spec.js
index be24b1a835..b30536cb27 100644
--- a/test/workers/pr/index.spec.js
+++ b/test/workers/pr/index.spec.js
@@ -91,7 +91,7 @@ describe('workers/pr', () => {
     });
     it('should not automerge if enabled and pr is unmergeable', async () => {
       config.automerge = true;
-      pr.isUnmergeable = true;
+      pr.isConflicted = true;
       await prWorker.checkAutoMerge(pr, config);
       expect(platform.mergePr.mock.calls.length).toBe(0);
     });
diff --git a/test/workers/repository/finalise/prune.spec.js b/test/workers/repository/finalise/prune.spec.js
index 9f81cedc3a..351dbc5b7f 100644
--- a/test/workers/repository/finalise/prune.spec.js
+++ b/test/workers/repository/finalise/prune.spec.js
@@ -44,7 +44,7 @@ describe('workers/repository/finalise/prune', () => {
       platform.getAllRenovateBranches.mockReturnValueOnce([
         'renovate/lock-file-maintenance',
       ]);
-      platform.getBranchPr = jest.fn(() => ({ isUnmergeable: true }));
+      platform.getBranchPr = jest.fn(() => ({ isConflicted: true }));
       await cleanup.pruneStaleBranches(config, [
         'renovate/lock-file-maintenance',
       ]);
diff --git a/test/workers/repository/onboarding/pr/index.spec.js b/test/workers/repository/onboarding/pr/index.spec.js
index 1f04304e21..ad10aab6d6 100644
--- a/test/workers/repository/onboarding/pr/index.spec.js
+++ b/test/workers/repository/onboarding/pr/index.spec.js
@@ -47,7 +47,7 @@ describe('workers/repository/onboarding/pr', () => {
       platform.getBranchPr.mockReturnValue({
         title: 'Configure Renovate',
         body: createPrBody,
-        isUnmergeable: true,
+        isConflicted: true,
       });
       await ensureOnboardingPr(config, [], branches);
       expect(platform.createPr.mock.calls).toHaveLength(0);
-- 
GitLab