From d822d4491b85ef608437663e48a51324142d92bd Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Mon, 10 Sep 2018 21:23:56 +0200 Subject: [PATCH] refactor(composer): gitfs lockfiles in-place --- lib/manager/composer/lock-file.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/manager/composer/lock-file.js b/lib/manager/composer/lock-file.js index d736d75e66..30c353e225 100644 --- a/lib/manager/composer/lock-file.js +++ b/lib/manager/composer/lock-file.js @@ -33,7 +33,9 @@ async function getLockFile( JSON.stringify(newPackageFileParsed) ); const localLockFileName = upath.join(config.localDir, lockFileName); - await fs.outputFile(localLockFileName, existingLockFileContent); + if (!config.gitFs) { + await fs.outputFile(localLockFileName, existingLockFileContent); + } const credentials = endpoints.find({ platform: 'github', host: 'api.github.com', @@ -63,19 +65,28 @@ async function getLockFile( logger.debug(`composer stderr:\n${stderr}`); const duration = process.hrtime(startTime); const seconds = Math.round(duration[0] + duration[1] / 1e9); - const newLockFileContent = await fs.readFile(localLockFileName, 'utf8'); logger.info( { seconds, type: 'composer.lock', stdout, stderr }, 'Generated lockfile' ); - if (newLockFileContent === existingLockFileContent) { - logger.debug('composer.lock is unchanged'); - return null; + // istanbul ignore if + if (config.gitFs) { + const status = await platform.getRepoStatus(); + if (!status.modified.includes(lockFileName)) { + return null; + } + } else { + const newLockFileContent = await fs.readFile(localLockFileName, 'utf8'); + + if (newLockFileContent === existingLockFileContent) { + logger.debug('composer.lock is unchanged'); + return null; + } } logger.debug('Returning updated composer.lock'); return { name: lockFileName, - contents: newLockFileContent, + contents: await fs.readFile(localLockFileName, 'utf8'), }; } catch (err) { logger.warn( -- GitLab