From 372b44526066fdefbb9188babeb3027d51a40d23 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Sun, 2 Jul 2017 06:21:24 +0200
Subject: [PATCH] refactor: set recreateClosed in group and lockFileMaintenance

---
 lib/config/definitions.js                    | 2 ++
 lib/workers/branch/index.js                  | 5 ++---
 test/config/__snapshots__/index.spec.js.snap | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/config/definitions.js b/lib/config/definitions.js
index 9c1ad285dc..262416f593 100644
--- a/lib/config/definitions.js
+++ b/lib/config/definitions.js
@@ -262,6 +262,7 @@ const options = [
     type: 'json',
     default: {
       enabled: true,
+      recreateClosed: true,
       branchName: 'renovate/lock-files',
       commitMessage: '{{semanticPrefix}}Update lock file',
       prTitle: '{{semanticPrefix}}Lock file maintenance',
@@ -301,6 +302,7 @@ const options = [
     description: 'Config if groupName is enabled',
     type: 'json',
     default: {
+      recreateClosed: true,
       branchName: template('branchName', 'group'),
       commitMessage: template('commitMessage', 'group'),
       prTitle: template('prTitle', 'group'),
diff --git a/lib/workers/branch/index.js b/lib/workers/branch/index.js
index 11880291fc..26266f1806 100644
--- a/lib/workers/branch/index.js
+++ b/lib/workers/branch/index.js
@@ -221,9 +221,8 @@ async function updateBranch(upgrades) {
 
   try {
     if (
-      upgrade0.upgradeType !== 'lockFileMaintenance' &&
-      upgrade0.groupName === null &&
-      !upgrade0.recreateClosed &&
+      // Groups and lock file maintenance should set this to true
+      upgrade0.recreateClosed === false &&
       (await upgrade0.api.checkForClosedPr(branchName, prTitle))
     ) {
       logger.info(`Skipping branch as matching closed PR already existed`);
diff --git a/test/config/__snapshots__/index.spec.js.snap b/test/config/__snapshots__/index.spec.js.snap
index 6d3c38b5e1..a7f4fad42b 100644
--- a/test/config/__snapshots__/index.spec.js.snap
+++ b/test/config/__snapshots__/index.spec.js.snap
@@ -7,6 +7,7 @@ Object {
   "enabled": true,
   "prBody": "This PR regenerates lock files to keep them up-to-date.",
   "prTitle": "{{semanticPrefix}}Lock file maintenance",
+  "recreateClosed": true,
   "schedule": "on monday",
 }
 `;
-- 
GitLab