From 4c6e3f79327d1dca19f9965d547e05f22b421330 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 7 Feb 2018 16:23:41 +0100 Subject: [PATCH] fix: use existing lock files when rebasing Check if a lock file already exists in the current *branch* and if so then use it as the base for generating the new lock file and not the master one. Ensures that simple rebases result in same result. Closes #1481 --- lib/workers/branch/lock-files.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/workers/branch/lock-files.js b/lib/workers/branch/lock-files.js index f2f9e67757..441628a338 100644 --- a/lib/workers/branch/lock-files.js +++ b/lib/workers/branch/lock-files.js @@ -232,7 +232,12 @@ async function writeExistingFiles(config) { } if (packageFile.packageLock && config.type !== 'lockFileMaintenance') { logger.debug(`Writing package-lock.json to ${basedir}`); - const packageLock = await platform.getFile(packageFile.packageLock); + const existingPackageLock = + (await platform.branchExists(config.branchName)) && + (await platform.getFile(packageFile.packageLock, config.branchName)); + const packageLock = + existingPackageLock || + (await platform.getFile(packageFile.packageLock)); await fs.outputFile( upath.join(basedir, 'package-lock.json'), packageLock @@ -242,7 +247,11 @@ async function writeExistingFiles(config) { } if (packageFile.yarnLock && config.type !== 'lockFileMaintenance') { logger.debug(`Writing yarn.lock to ${basedir}`); - const yarnLock = await platform.getFile(packageFile.yarnLock); + const existingYarnLock = + (await platform.branchExists(config.branchName)) && + (await platform.getFile(packageFile.yarnLock, config.branchName)); + const yarnLock = + existingYarnLock || (await platform.getFile(packageFile.yarnLock)); await fs.outputFile(upath.join(basedir, 'yarn.lock'), yarnLock); } else { await fs.remove(upath.join(basedir, 'yarn.lock')); -- GitLab