Skip to content
Snippets Groups Projects
Unverified Commit c8c0e1b4 authored by gone-for-coding's avatar gone-for-coding Committed by GitHub
Browse files

fix(pre-commit): Gitlab Custom RegistryUrl not honored (#25682)


Co-authored-by: default avatarRhys Arkins <rhys@arkins.net>
parent 53401eb3
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,16 @@ repos: ...@@ -23,6 +23,16 @@ repos:
rev: 19.3b0 rev: 19.3b0
hooks: hooks:
- id: black - 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 - repo: https://github.com/prettier/pre-commit
# should accept different order of keys # should accept different order of keys
hooks: hooks:
......
...@@ -31,6 +31,26 @@ exports[`modules/manager/pre-commit/extract extractPackageFile() extracts from c ...@@ -31,6 +31,26 @@ exports[`modules/manager/pre-commit/extract extractPackageFile() extracts from c
"depType": "repository", "depType": "repository",
"packageName": "psf/black", "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", "currentValue": "v2.1.2",
"datasource": "github-tags", "datasource": "github-tags",
......
...@@ -84,6 +84,16 @@ describe('modules/manager/pre-commit/extract', () => { ...@@ -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: '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' },
{ depName: 'prettier/pre-commit', currentValue: 'v2.1.2' }, { depName: 'prettier/pre-commit', currentValue: 'v2.1.2' },
{ skipReason: 'invalid-url' }, { skipReason: 'invalid-url' },
......
...@@ -32,10 +32,20 @@ function determineDatasource( ...@@ -32,10 +32,20 @@ function determineDatasource(
logger.debug({ repository, hostname }, 'Found github dependency'); logger.debug({ repository, hostname }, 'Found github dependency');
return { datasource: GithubTagsDatasource.id }; return { datasource: GithubTagsDatasource.id };
} }
if (hostname === 'gitlab.com' || detectPlatform(repository) === 'gitlab') { if (hostname === 'gitlab.com') {
logger.debug({ repository, hostname }, 'Found gitlab dependency'); logger.debug({ repository, hostname }, 'Found gitlab dependency');
return { datasource: GitlabTagsDatasource.id }; 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 hostUrl = 'https://' + hostname;
const res = find({ url: hostUrl }); const res = find({ url: hostUrl });
if (is.emptyObject(res)) { if (is.emptyObject(res)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment