Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): filter out invalid massaged packageRules #16778

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/config/massage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ describe('config/massage', () => {
expect(res.packageRules).toHaveLength(3);
});

it('filters packageRules with only match/exclude', () => {
const config: RenovateConfig = {
packageRules: [
{
matchBaseBranches: ['main'],
major: {
enabled: true,
},
},
],
};
const res = massage.massageConfig(config);
expect(res.packageRules).toHaveLength(1);
});

it('does not massage lockFileMaintenance', () => {
const config: RenovateConfig = {
packageRules: [
Expand Down
13 changes: 12 additions & 1 deletion lib/config/massage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function massageConfig(config: RenovateConfig): RenovateConfig {
}
}
if (is.nonEmptyArray(massagedConfig.packageRules)) {
const newRules: PackageRule[] = [];
let newRules: PackageRule[] = [];
const updateTypes: UpdateType[] = [
'major',
'minor',
Expand Down Expand Up @@ -74,6 +74,17 @@ export function massageConfig(config: RenovateConfig): RenovateConfig {
delete rule[updateType];
});
}
newRules = newRules.filter((rule) => {
if (
Object.keys(rule).every(
(key) => key.startsWith('match') || key.startsWith('exclude')
)
) {
// Exclude rules which contain only match or exclude options
return false;
}
return true;
});
massagedConfig.packageRules = newRules;
}
return massagedConfig;
Expand Down