Skip to content

Commit

Permalink
feat(package-rules)!: remove fuzzy matchPaths matching (#22394)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jun 15, 2023
1 parent 4e80b37 commit 058afd0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 33 deletions.
5 changes: 0 additions & 5 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2287,11 +2287,6 @@ The following matches any file in directories starting with `app/`:
}
```

<!-- prettier-ignore -->
!!! warning
Partial matches for `matchPaths` are deprecated.
Please use a `minimatch` glob pattern or switch to [`matchFiles`](#matchfiles) if you need exact matching.

### matchSourceUrlPrefixes

Here's an example of where you use this to group together all packages from the `renovatebot` GitHub org:
Expand Down
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 })
);
}
}

0 comments on commit 058afd0

Please sign in to comment.