Skip to content
Snippets Groups Projects
Commit 805ae952 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: rebase if package file not found in existing branch

parent 7886c7a8
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment