Skip to content
Snippets Groups Projects
Unverified Commit 88860db2 authored by jsperling-schwarz's avatar jsperling-schwarz Committed by GitHub
Browse files

fix(datasource/go): private repositories on azure (#26984)


Co-authored-by: default avatarRhys Arkins <rhys@arkins.net>
parent 73cc089f
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ describe('modules/datasource/go/base', () => {
${'github.com/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
${'bitbucket.org/foo/bar'} | ${'bitbucket-tags'} | ${'foo/bar'}
${'code.cloudfoundry.org/lager'} | ${'github-tags'} | ${'cloudfoundry/lager'}
${'dev.azure.com/foo/bar/_git/baz.git'} | ${'git-tags'} | ${'https://dev.azure.com/foo/bar/_git/baz'}
${'dev.azure.com/foo/bar/baz.git'} | ${'git-tags'} | ${'https://dev.azure.com/foo/bar/_git/baz'}
`(
'$module -> $datasource: $packageName',
async ({ module, datasource, packageName }) => {
......@@ -347,21 +349,31 @@ describe('modules/datasource/go/base', () => {
it('handles go-import with azure devops source', async () => {
const meta =
'<meta name="go-import" content="dev.azure.com/my-organization/my-project/_git/my-repo.git git https://dev.azure.com/my-organization/my-project/_git/my-repo.git" />';
'<meta name="go-import" content="org.visualstudio.com/my-project/_git/my-repo.git git https://org.visualstudio.com/my-project/_git/my-repo.git" />';
httpMock
.scope('https://dev.azure.com')
.get('/my-organization/my-project/_git/my-repo.git?go-get=1')
.scope('https://org.visualstudio.com')
.get('/my-project/_git/my-repo.git?go-get=1')
.reply(200, meta);
const res = await BaseGoDatasource.getDatasource(
'dev.azure.com/my-organization/my-project/_git/my-repo.git',
'org.visualstudio.com/my-project/_git/my-repo.git',
);
expect(res).toEqual({
datasource: GitTagsDatasource.id,
packageName:
'https://dev.azure.com/my-organization/my-project/_git/my-repo',
packageName: 'https://org.visualstudio.com/my-project/_git/my-repo',
});
});
it('returns null for invalid azure devops source', async () => {
httpMock
.scope('https://dev.azure.com')
.get('/foo/bar.git?go-get=1')
.reply(200);
const res = await BaseGoDatasource.getDatasource(
'dev.azure.com/foo/bar.git',
);
expect(res).toBeNull();
});
it('handles uncommon imports', async () => {
......
......@@ -71,6 +71,26 @@ export class BaseGoDatasource {
};
}
if (goModule.startsWith('dev.azure.com/')) {
const split = goModule.split('/');
if ((split.length > 4 && split[3] === '_git') || split.length > 3) {
const packageName =
'https://dev.azure.com/' +
split[1] +
'/' +
split[2] +
'/_git/' +
(split[3] === '_git' ? split[4] : split[3]).replace(
regEx(/\.git$/),
'',
);
return {
datasource: GitTagsDatasource.id,
packageName,
};
}
}
return await BaseGoDatasource.goGetDatasource(goModule);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment