From 19949f2604ea773f18e96d9aeae35d98b64bd817 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Thu, 12 Oct 2017 18:55:46 +0200
Subject: [PATCH] fix: migrate automergeMajor automergeMinor automergePatch
 (#922)

This is a misconfiguration by a user but no harm in adding it to migrations.
---
 lib/config/migration.js                          | 15 +++++++++++++++
 test/config/__snapshots__/migration.spec.js.snap |  9 +++++++++
 test/config/migration.spec.js                    |  3 +++
 3 files changed, 27 insertions(+)

diff --git a/lib/config/migration.js b/lib/config/migration.js
index df9c5a4ba7..3b07c09776 100644
--- a/lib/config/migration.js
+++ b/lib/config/migration.js
@@ -33,6 +33,21 @@ function migrateConfig(config, parentConfig) {
     if (removedOptions.includes(key)) {
       isMigrated = true;
       delete migratedConfig[key];
+    } else if (key === 'automergeMinor') {
+      isMigrated = true;
+      migratedConfig.minor = migratedConfig.minor || {};
+      migratedConfig.minor.automerge = val;
+      delete migratedConfig[key];
+    } else if (key === 'automergeMajor') {
+      isMigrated = true;
+      migratedConfig.major = migratedConfig.major || {};
+      migratedConfig.major.automerge = val;
+      delete migratedConfig[key];
+    } else if (key === 'automergePatch') {
+      isMigrated = true;
+      migratedConfig.patch = migratedConfig.patch || {};
+      migratedConfig.patch.automerge = val;
+      delete migratedConfig[key];
     } else if (key === 'ignoreNodeModules') {
       isMigrated = true;
       delete migratedConfig.ignoreNodeModules;
diff --git a/test/config/__snapshots__/migration.spec.js.snap b/test/config/__snapshots__/migration.spec.js.snap
index b9de284329..dab695f658 100644
--- a/test/config/__snapshots__/migration.spec.js.snap
+++ b/test/config/__snapshots__/migration.spec.js.snap
@@ -26,6 +26,12 @@ Object {
   "lockFileConfig": Object {
     "automerge": true,
   },
+  "major": Object {
+    "automerge": false,
+  },
+  "minor": Object {
+    "automerge": true,
+  },
   "onboarding": false,
   "optionalDependencies": Object {
     "major": Object {
@@ -58,6 +64,9 @@ Object {
       ],
     },
   ],
+  "patch": Object {
+    "automerge": true,
+  },
   "prTitle": "some pr title",
   "schedule": "on the first day of the month",
   "semanticPrefix": "fix(deps):",
diff --git a/test/config/migration.spec.js b/test/config/migration.spec.js
index 05e409cbd1..a6fc6c2436 100644
--- a/test/config/migration.spec.js
+++ b/test/config/migration.spec.js
@@ -9,6 +9,9 @@ describe('config/migration', () => {
         maintainYarnLock: true,
         onboarding: 'false',
         automerge: 'none',
+        automergeMajor: false,
+        automergeMinor: true,
+        automergePatch: true,
         ignoreNodeModules: true,
         autodiscover: 'true',
         schedule: 'on the last day of the month',
-- 
GitLab