Skip to content

Commit

Permalink
fix(autodiscover): minimatch repos with leading dots (#25516)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Nov 1, 2023
1 parent d72b4c3 commit 00ddca0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/workers/global/autodiscover.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ describe('workers/global/autodiscover', () => {
expect(res.repositories).toEqual(['project/repo']);
});

it('filters autodiscovered dot repos', async () => {
config.autodiscover = true;
config.autodiscoverFilter = ['project/*'];
config.platform = 'github';
hostRules.find = jest.fn(() => ({
token: 'abc',
}));
ghApi.getRepos = jest.fn(() =>
Promise.resolve(['project/repo', 'project/.github'])
);
const res = await autodiscoverRepositories(config);
expect(res.repositories).toEqual(['project/repo', 'project/.github']);
});

it('filters autodiscovered github repos but nothing matches', async () => {
config.autodiscover = true;
config.autodiscoverFilter = ['project/re*'];
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/global/autodiscover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function applyFilters(repos: string[], filters: string[]): string[] {
}
res = repos.filter(autodiscoveryPred);
} else {
res = repos.filter(minimatch.filter(filter, { nocase: true }));
res = repos.filter(minimatch.filter(filter, { dot: true, nocase: true }));
}
for (const repository of res) {
matched.add(repository);
Expand Down

0 comments on commit 00ddca0

Please sign in to comment.