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(package-rules)!: remove fuzzy matchPaths matching #22394

Merged
merged 1 commit into from
May 24, 2023
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
2 changes: 1 addition & 1 deletion lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ const options: RenovateOptions[] = [
{
name: 'matchPaths',
description:
'List of strings or glob patterns to match against package files. Only works inside a `packageRules` object.',
'List of glob patterns to match against package files. Only works inside a `packageRules` object.',
type: 'array',
subType: 'string',
stage: 'repository',
Expand Down
2 changes: 1 addition & 1 deletion lib/util/package-rules/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ describe('util/package-rules/index', () => {
...config,
depName: 'test',
});
expect(res3.x).toBeDefined();
expect(res3.x).toBeUndefined();
});

it('empty rules', () => {
Expand Down
11 changes: 2 additions & 9 deletions lib/util/package-rules/paths.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('util/package-rules/paths', () => {
expect(result).toBeFalse();
});

it('should return true and log warning on partial match only', () => {
it('should return false on partial match only', () => {
const result = pathsMatcher.matches(
{
packageFile: 'opentelemetry/http/package.json',
Expand All @@ -26,14 +26,7 @@ describe('util/package-rules/paths', () => {
matchPaths: ['opentelemetry/http'],
}
);
expect(result).toBeTrue();
expect(logger.warn).toHaveBeenCalledWith(
{
packageFile: 'opentelemetry/http/package.json',
rulePath: 'opentelemetry/http',
},
'Partial matches for `matchPaths` are deprecated. Please use a minimatch glob pattern or switch to `matchFiles` if you need exact matching.'
);
expect(result).toBeFalse();
});

it('should return true and not log warning on partial and glob match', () => {
Expand Down
20 changes: 3 additions & 17 deletions lib/util/package-rules/paths.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import is from '@sindresorhus/is';
import { minimatch } from 'minimatch';
import type { PackageRule, PackageRuleInputConfig } from '../../config/types';
import { logger } from '../../logger';
import { Matcher } from './base';

export class PathsMatcher extends Matcher {
Expand All @@ -16,21 +15,8 @@ export class PathsMatcher extends Matcher {
return false;
}

return matchPaths.some((rulePath) => {
if (minimatch(packageFile, rulePath, { dot: true })) {
return true;
}

if (packageFile.includes(rulePath)) {
logger.warn(
{
rulePath,
packageFile,
},
'Partial matches for `matchPaths` are deprecated. Please use a minimatch glob pattern or switch to `matchFiles` if you need exact matching.'
);
return true;
}
});
return matchPaths.some((rulePath) =>
minimatch(packageFile, rulePath, { dot: true })
);
}
}