Skip to content

Commit

Permalink
fix(platform/bitbucket-server): do not force lowercase project keys i…
Browse files Browse the repository at this point in the history
…n autodiscover mode (#23261)

Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
Churro and rarkins authored Jul 9, 2023
1 parent 76cacd5 commit 9d3d7a9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 }));
}
for (const repository of res) {
matched.add(repository);
Expand Down

0 comments on commit 9d3d7a9

Please sign in to comment.