diff --git a/lib/modules/datasource/go/base.spec.ts b/lib/modules/datasource/go/base.spec.ts
index 2fa96c269150cd..3c8a08400de554 100644
--- a/lib/modules/datasource/go/base.spec.ts
+++ b/lib/modules/datasource/go/base.spec.ts
@@ -16,12 +16,14 @@ const hostRules = mocked(_hostRules);
describe('modules/datasource/go/base', () => {
describe('simple cases', () => {
it.each`
- module | datasource | packageName
- ${'gopkg.in/foo'} | ${'github-tags'} | ${'go-foo/foo'}
- ${'gopkg.in/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
- ${'github.com/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
- ${'bitbucket.org/foo/bar'} | ${'bitbucket-tags'} | ${'foo/bar'}
- ${'code.cloudfoundry.org/lager'} | ${'github-tags'} | ${'cloudfoundry/lager'}
+ module | datasource | packageName
+ ${'gopkg.in/foo'} | ${'github-tags'} | ${'go-foo/foo'}
+ ${'gopkg.in/foo/bar'} | ${'github-tags'} | ${'foo/bar'}
+ ${'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,23 +349,33 @@ describe('modules/datasource/go/base', () => {
it('handles go-import with azure devops source', async () => {
const meta =
- '';
+ '';
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 () => {
const meta =
'';
diff --git a/lib/modules/datasource/go/base.ts b/lib/modules/datasource/go/base.ts
index d29bc057148584..375987839bfb84 100644
--- a/lib/modules/datasource/go/base.ts
+++ b/lib/modules/datasource/go/base.ts
@@ -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);
}