Skip to content

Commit

Permalink
fix(pre-commit): Gitlab Custom RegistryUrl not honored (#25682)
Browse files Browse the repository at this point in the history
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
gone-for-coding and rarkins committed Nov 13, 2023
1 parent 53401eb commit c8c0e1b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
Expand Up @@ -23,6 +23,16 @@ repos:
rev: 19.3b0
hooks:
- id: black
- repo: https://gitlab.mycompany.com/my/dep
# should also detect custom gitlab registry
rev: v42.0
hooks:
- id: custom-hook
- repo: https://gitlab.mycompany.com/my/dep
# should also detect http for custom gitlab registry
rev: v42.0
hooks:
- id: custom-hook
- repo: https://github.com/prettier/pre-commit
# should accept different order of keys
hooks:
Expand Down
20 changes: 20 additions & 0 deletions lib/modules/manager/pre-commit/__snapshots__/extract.spec.ts.snap
Expand Up @@ -31,6 +31,26 @@ exports[`modules/manager/pre-commit/extract extractPackageFile() extracts from c
"depType": "repository",
"packageName": "psf/black",
},
{
"currentValue": "v42.0",
"datasource": "gitlab-tags",
"depName": "my/dep",
"depType": "repository",
"packageName": "my/dep",
"registryUrls": [
"https://gitlab.mycompany.com",
],
},
{
"currentValue": "v42.0",
"datasource": "gitlab-tags",
"depName": "my/dep",
"depType": "repository",
"packageName": "my/dep",
"registryUrls": [
"https://gitlab.mycompany.com",
],
},
{
"currentValue": "v2.1.2",
"datasource": "github-tags",
Expand Down
10 changes: 10 additions & 0 deletions lib/modules/manager/pre-commit/extract.spec.ts
Expand Up @@ -84,6 +84,16 @@ describe('modules/manager/pre-commit/extract', () => {
{ depName: 'psf/black', currentValue: '19.3b0' },
{ depName: 'psf/black', currentValue: '19.3b0' },
{ depName: 'psf/black', currentValue: '19.3b0' },
{
depName: 'my/dep',
currentValue: 'v42.0',
registryUrls: ['https://gitlab.mycompany.com'],
},
{
depName: 'my/dep',
currentValue: 'v42.0',
registryUrls: ['https://gitlab.mycompany.com'],
},
{ depName: 'prettier/pre-commit', currentValue: 'v2.1.2' },
{ depName: 'prettier/pre-commit', currentValue: 'v2.1.2' },
{ skipReason: 'invalid-url' },
Expand Down
12 changes: 11 additions & 1 deletion lib/modules/manager/pre-commit/extract.ts
Expand Up @@ -32,10 +32,20 @@ function determineDatasource(
logger.debug({ repository, hostname }, 'Found github dependency');
return { datasource: GithubTagsDatasource.id };
}
if (hostname === 'gitlab.com' || detectPlatform(repository) === 'gitlab') {
if (hostname === 'gitlab.com') {
logger.debug({ repository, hostname }, 'Found gitlab dependency');
return { datasource: GitlabTagsDatasource.id };
}
if (detectPlatform(repository) === 'gitlab') {
logger.debug(
{ repository, hostname },
'Found gitlab dependency with custom registryUrl',
);
return {
datasource: GitlabTagsDatasource.id,
registryUrls: ['https://' + hostname],
};
}
const hostUrl = 'https://' + hostname;
const res = find({ url: hostUrl });
if (is.emptyObject(res)) {
Expand Down

0 comments on commit c8c0e1b

Please sign in to comment.