Skip to content

Commit

Permalink
fix(config-migration): skip migration of package.json (#33122)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh authored Dec 16, 2024
1 parent 8453d73 commit 66dcb61
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/workers/repository/config-migration/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ describe('workers/repository/config-migration/index', () => {
expect(ensureConfigMigrationPr).toHaveBeenCalledTimes(0);
});

it('skips pr creation if config found in package.json', async () => {
const branchList: string[] = [];
mockedFunction(MigratedDataFactory.getAsync).mockResolvedValue({
content,
indent: partial<Indent>(),
filename: 'package.json',
});
const res = await configMigration(config, branchList);
expect(res).toMatchObject({ result: 'no-migration' });
expect(checkConfigMigrationBranch).toHaveBeenCalledTimes(0);
expect(ensureConfigMigrationPr).toHaveBeenCalledTimes(0);
});

it('creates migration pr if needed', async () => {
const branchList: string[] = [];
mockedFunction(checkConfigMigrationBranch).mockResolvedValue({
Expand Down
8 changes: 8 additions & 0 deletions lib/workers/repository/config-migration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export async function configMigration(
return { result: 'no-migration' };
}

if (migratedConfigData.filename === 'package.json') {
logger.debug(
' Using package.json for Renovate config is deprecated - please use a dedicated configuration file instead. Skipping config migration.',
);
MigratedDataFactory.reset();
return { result: 'no-migration' };
}

const res = await checkConfigMigrationBranch(config, migratedConfigData);

// migration needed but not demanded by user
Expand Down

0 comments on commit 66dcb61

Please sign in to comment.