diff --git a/lib/workers/branch/get-updated.js b/lib/workers/branch/get-updated.js index 62e396bedf5eff4e9169fa607c05a8d2db5ba43c..32608026e576c6a7f7a5cb88929e60608c1ba305 100644 --- a/lib/workers/branch/get-updated.js +++ b/lib/workers/branch/get-updated.js @@ -22,6 +22,14 @@ async function getUpdatedPackageFiles(config) { const existingContent = updatedFileContents[packageFile] || (await platform.getFile(packageFile, config.parentBranch)); + // istanbul ignore if + if (config.parentBranch && !existingContent) { + logger.info('Rebasing branch after file not found'); + return getUpdatedPackageFiles({ + ...config, + parentBranch: undefined, + }); + } let newContent = existingContent; const updateDependency = get(manager, 'updateDependency'); newContent = await updateDependency(existingContent, upgrade); diff --git a/test/workers/branch/get-updated.spec.js b/test/workers/branch/get-updated.spec.js index ee4a5f4201b2744484d6539abb18662f43df60d1..168a22cc618c60daa1ab13eabd0e2a1225dbbb17 100644 --- a/test/workers/branch/get-updated.spec.js +++ b/test/workers/branch/get-updated.spec.js @@ -16,6 +16,7 @@ describe('workers/branch/get-updated', () => { composer.updateDependency = jest.fn(); composer.getArtifacts = jest.fn(); npm.updateDependency = jest.fn(); + platform.getFile.mockReturnValueOnce('existing content'); }); it('handles empty', async () => { const res = await getUpdatedPackageFiles(config);