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

fix(platform/bitbucket-server): do not force lowercase project keys in autodiscover mode #23261

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/usage/self-hosted-configuration.md
Expand Up @@ -103,6 +103,8 @@ RENOVATE_AUTODISCOVER_FILTER="/myapp/(readme\.md|src/.*)/"
}
```

The search for repositories is case-insensitive.

**Regex**:

All text inside the start and end `/` will be treated as a regular expression.
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/bitbucket-server/index.spec.ts
Expand Up @@ -266,7 +266,7 @@ describe('modules/platform/bitbucket-server/index', () => {
values: [repoMock(url, 'SOME', 'repo')],
start: 0,
});
expect(await bitbucket.getRepos()).toEqual(['some/repo']);
expect(await bitbucket.getRepos()).toEqual(['SOME/repo']);
});
});

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/bitbucket-server/index.ts
Expand Up @@ -110,7 +110,7 @@ export async function getRepos(): Promise<string[]> {
);
const result = repos.map(
(r: { project: { key: string }; slug: string }) =>
`${r.project.key.toLowerCase()}/${r.slug}`
`${r.project.key}/${r.slug}`
);
logger.debug({ result }, 'result of getRepos()');
return result;
Expand Down
14 changes: 14 additions & 0 deletions lib/workers/global/autodiscover.spec.ts
Expand Up @@ -164,4 +164,18 @@ describe('workers/global/autodiscover', () => {
const res = await autodiscoverRepositories(config);
expect(res.repositories).toEqual(expectedRepositories);
});

it('filters autodiscovered github repos case-insensitive', async () => {
config.autodiscover = true;
config.autodiscoverFilter = ['project/re*'];
config.platform = 'github';
hostRules.find = jest.fn(() => ({
token: 'abc',
}));
ghApi.getRepos = jest.fn(() =>
Promise.resolve(['project/repo', 'PROJECT/repo2'])
);
const res = await autodiscoverRepositories(config);
expect(res.repositories).toEqual(['project/repo', 'PROJECT/repo2']);
});
});
2 changes: 1 addition & 1 deletion lib/workers/global/autodiscover.ts
Expand Up @@ -105,7 +105,7 @@ export function applyFilters(repos: string[], filters: string[]): string[] {
}
res = repos.filter(autodiscoveryPred);
} else {
res = repos.filter(minimatch.filter(filter));
res = repos.filter(minimatch.filter(filter, { nocase: true }));
rarkins marked this conversation as resolved.
Show resolved Hide resolved
}
for (const repository of res) {
matched.add(repository);
Expand Down