diff --git a/lib/datasource/go.js b/lib/datasource/go.js index 3821af9336b75764ae5fbeecc549ec1d073272ac..defd99232ff7bf43412c52dfb831c4ceda168851 100644 --- a/lib/datasource/go.js +++ b/lib/datasource/go.js @@ -5,9 +5,7 @@ module.exports = { getPkgReleases, }; -async function getPkgReleases(purl, config) { - const { fullname: name } = purl; - logger.trace(`go.getPkgReleases(${name})`); +async function getSourcePurl(name) { const pkgUrl = 'https://' + name + '?go-get=1'; try { const res = (await got(pkgUrl, { @@ -18,7 +16,7 @@ async function getPkgReleases(purl, config) { ); if (sourceMatch) { const [, sourceUrl] = sourceMatch; - logger.debug({ name, sourceUrl }, 'Go lookup sourceUrl'); + logger.debug({ depName: name, sourceUrl }, 'Go lookup sourceUrl'); if (sourceUrl && sourceUrl.startsWith('https://github.com/')) { const githubPurl = { fullname: sourceUrl @@ -26,10 +24,8 @@ async function getPkgReleases(purl, config) { .replace(/\/$/, ''), qualifiers: {}, }; - const githubTags = await github.getPkgReleases(githubPurl, config); - return githubTags; + return githubPurl; } - logger.info('Unknown go source: ' + sourceUrl); } else { logger.trace({ depName: name }, 'No go-source header found'); } @@ -46,3 +42,14 @@ async function getPkgReleases(purl, config) { return null; } } + +async function getPkgReleases(purl, config) { + const { fullname: name } = purl; + logger.trace(`go.getPkgReleases(${name})`); + const githubPurl = await getSourcePurl(name); + if (githubPurl) { + const githubTags = await github.getPkgReleases(githubPurl, config); + return githubTags; + } + return null; +}