diff --git a/lib/datasource/go/__snapshots__/index.spec.ts.snap b/lib/datasource/go/__snapshots__/index.spec.ts.snap index f897c9532e9a9d2b07cf9fec047dc9adc7e9a606..625877a6e8602243264ee5c246d2c76903bcd0da 100644 --- a/lib/datasource/go/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/go/__snapshots__/index.spec.ts.snap @@ -570,3 +570,28 @@ Array [ }, ] `; + +exports[`datasource/go getReleases works for nested modules on github v2+ major upgrades 1`] = ` +Array [ + Object { + "headers": Object { + "accept": "application/vnd.github.v3+json", + "accept-encoding": "gzip, deflate", + "host": "api.github.com", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://api.github.com/repos/x/text/tags?per_page=100", + }, + Object { + "headers": Object { + "accept": "application/vnd.github.v3+json", + "accept-encoding": "gzip, deflate", + "host": "api.github.com", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://api.github.com/repos/x/text/releases?per_page=100", + }, +] +`; diff --git a/lib/datasource/go/index.spec.ts b/lib/datasource/go/index.spec.ts index 276712b1b894ae2485671be74689677f746b5285..ea5993f52093445ea9ea696ad5d7325db7d71849 100644 --- a/lib/datasource/go/index.spec.ts +++ b/lib/datasource/go/index.spec.ts @@ -418,5 +418,32 @@ describe('datasource/go', () => { httpMock.reset(); } }); + it('works for nested modules on github v2+ major upgrades', async () => { + const pkg = { datasource, depName: 'github.com/x/text/b/v2' }; + const tags = [ + { name: 'a/v1.0.0' }, + { name: 'v5.0.0' }, + { name: 'b/v2.0.0' }, + { name: 'b/v3.0.0' }, + ]; + + httpMock.setup(); + httpMock + .scope('https://api.github.com/') + .get('/repos/x/text/tags?per_page=100') + .reply(200, tags) + .get('/repos/x/text/releases?per_page=100') + .reply(200, []); + + const result = await getPkgReleases(pkg); + expect(result.releases).toEqual([ + { gitRef: 'b/v2.0.0', version: 'v2.0.0' }, + { gitRef: 'b/v3.0.0', version: 'v3.0.0' }, + ]); + + const httpCalls = httpMock.getTrace(); + expect(httpCalls).toMatchSnapshot(); + httpMock.reset(); + }); }); }); diff --git a/lib/datasource/go/index.ts b/lib/datasource/go/index.ts index a1d8add342c872923d4b1d2d76e2bdc49514edf8..ba341aea2b3c6e2119a07525b66736cdf0e1af4b 100644 --- a/lib/datasource/go/index.ts +++ b/lib/datasource/go/index.ts @@ -181,7 +181,7 @@ export async function getReleases({ * and that tag should be used instead of just va.b.c, although for compatibility * the old behaviour stays the same. */ - const nameParts = lookupName.split('/'); + const nameParts = lookupName.replace(/\/v\d+$/, '').split('/'); logger.trace({ nameParts, releases: res.releases }, 'go.getReleases'); if (nameParts.length > 3) { const prefix = nameParts.slice(3, nameParts.length).join('/');