Skip to content

Commit

Permalink
feat(packageRules): set skipReason=package-rules (#28952)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed May 9, 2024
1 parent 2056e2d commit bf22e13
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/config/types.ts
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
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
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
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

0 comments on commit bf22e13

Please sign in to comment.