Skip to content

Commit

Permalink
fix: resolve repoConfig.packageRules.extends with repo config (#14688)
Browse files Browse the repository at this point in the history
  • Loading branch information
anomiex committed Mar 25, 2022
1 parent 580590b commit e2b6466
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/config/options/index.ts
Expand Up @@ -152,8 +152,7 @@ const options: RenovateOptions[] = [
},
{
name: 'extends',
description:
'Configuration presets to use/extend. Note: does not work if configured in config.js.',
description: 'Configuration presets to use/extend.',
stage: 'package',
type: 'array',
subType: 'string',
Expand Down
28 changes: 20 additions & 8 deletions lib/workers/repository/init/merge.spec.ts
Expand Up @@ -185,16 +185,28 @@ describe('workers/repository/init/merge', () => {
it('migrates nested config', async () => {
git.getFileList.mockResolvedValue(['renovate.json']);
fs.readLocalFile.mockResolvedValue('{}');
migrateAndValidate.migrateAndValidate.mockResolvedValue({
warnings: [],
errors: [],
});
migrate.migrateConfig.mockReturnValueOnce({
migrateAndValidate.migrateAndValidate.mockImplementation((_, c) =>
Promise.resolve({
...c,
warnings: [],
errors: [],
})
);
migrate.migrateConfig.mockImplementation((c) => ({
isMigrated: true,
migratedConfig: {},
migratedConfig: c,
}));
config.extends = [':automergeAll'];
config.packageRules = [{ extends: ['monorepo:react'] }];
const ret = await mergeRenovateConfig(config);
expect(ret).toMatchObject({
automerge: true,
packageRules: [
{
matchSourceUrlPrefixes: ['https://github.com/facebook/react'],
},
],
});
config.extends = [':automergeDisabled'];
expect(await mergeRenovateConfig(config)).toBeDefined();
});
it('continues if no errors', async () => {
git.getFileList.mockResolvedValue(['package.json', '.renovaterc.json']);
Expand Down
7 changes: 7 additions & 0 deletions lib/workers/repository/init/merge.ts
Expand Up @@ -177,6 +177,13 @@ export async function mergeRenovateConfig(
];
delete returnConfig.extends;
}
if (is.nonEmptyArray(returnConfig.packageRules)) {
configFileParsed.packageRules = [
...returnConfig.packageRules,
...(configFileParsed.packageRules || []),
];
delete returnConfig.packageRules;
}
checkForRepoConfigError(repoConfig);
const migratedConfig = await migrateAndValidate(config, configFileParsed);
if (migratedConfig.errors.length) {
Expand Down

0 comments on commit e2b6466

Please sign in to comment.