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

feat(packageRules): set skipReason=package-rules #28952

Merged
merged 1 commit into from
May 9, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PlatformId } from '../constants';
import type { LogLevelRemap } from '../logger/types';
import type { CustomManager } from '../modules/manager/custom/types';
import type { RepoSortMethod, SortMethod } from '../modules/platform/types';
import type { HostRule } from '../types';
import type { HostRule, SkipReason } from '../types';
import type { GitNoVerifyOption } from '../util/git/types';
import type { MergeConfidence } from '../util/merge-confidence/types';

Expand Down Expand Up @@ -544,6 +544,8 @@ export interface PackageRuleInputConfig extends Record<string, unknown> {
releaseTimestamp?: string | null;
repository?: string;
currentVersionTimestamp?: string;
enabled?: boolean;
skipReason?: SkipReason;
}

export interface ConfigMigration {
Expand Down
1 change: 1 addition & 0 deletions lib/types/skip-reason.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type SkipReason =
| 'no-source'
| 'non-hex-dep-types'
| 'not-a-version'
| 'package-rules'
| 'path-dependency'
| 'placeholder-url'
| 'unknown-engines'
Expand Down
28 changes: 28 additions & 0 deletions lib/util/package-rules/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,34 @@ describe('util/package-rules/index', () => {
expect(res2.automerge).toBeFalse();
});

it('sets skipReason=package-rules if enabled=false', () => {
const dep: any = {
depName: 'foo',
packageRules: [
{
enabled: false,
},
],
};
const res = applyPackageRules(dep);
expect(res.enabled).toBeFalse();
expect(res.skipReason).toBe('package-rules');
});

it('skips skipReason=package-rules if enabled=true', () => {
const dep: any = {
enabled: false,
depName: 'foo',
packageRules: [
{
enabled: false,
},
],
};
const res = applyPackageRules(dep);
expect(res.skipReason).toBeUndefined();
});

it('matches anything if missing inclusive rules', () => {
const config: TestConfig = {
packageRules: [
Expand Down
3 changes: 3 additions & 0 deletions lib/util/package-rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export function applyPackageRules<T extends PackageRuleInputConfig>(
lower: true,
});
}
if (toApply.enabled === false && config.enabled !== false) {
config.skipReason = 'package-rules';
}
config = mergeChildConfig(config, toApply);
}
}
Expand Down