From 36feb03d1c18886c0196ef1cf388253a7549fd2b Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 21 Nov 2018 22:51:49 +0100 Subject: [PATCH] fix(go): filter out versions without leading v Closes #2850 --- lib/datasource/go.js | 5 +++++ test/datasource/__snapshots__/go.spec.js.snap | 8 ++++++-- test/datasource/go.spec.js | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/datasource/go.js b/lib/datasource/go.js index 1355c791ed..78aa8ae4b4 100644 --- a/lib/datasource/go.js +++ b/lib/datasource/go.js @@ -73,6 +73,11 @@ async function getPkgReleases(purl, config) { const githubPurl = await getSourcePurl(name); if (githubPurl) { const githubTags = await github.getPkgReleases(githubPurl, config); + if (githubTags.releases) { + githubTags.releases = githubTags.releases.filter( + release => release.version && release.version.startsWith('v') + ); + } return githubTags; } return null; diff --git a/test/datasource/__snapshots__/go.spec.js.snap b/test/datasource/__snapshots__/go.spec.js.snap index 603e65b9d7..a1b210dc4d 100644 --- a/test/datasource/__snapshots__/go.spec.js.snap +++ b/test/datasource/__snapshots__/go.spec.js.snap @@ -3,8 +3,12 @@ exports[`datasource/go getPkgReleases processes real data 1`] = ` Object { "releases": Array [ - 1, - 2, + Object { + "version": "v1.0.0", + }, + Object { + "version": "v2.0.0", + }, ], } `; diff --git a/test/datasource/go.spec.js b/test/datasource/go.spec.js index 17137d9b26..b711a4b9da 100644 --- a/test/datasource/go.spec.js +++ b/test/datasource/go.spec.js @@ -67,7 +67,9 @@ describe('datasource/go', () => { got.mockReturnValueOnce({ body: res1, }); - github.getPkgReleases.mockReturnValueOnce({ releases: [1, 2] }); + github.getPkgReleases.mockReturnValueOnce({ + releases: [{ version: 'v1.0.0' }, { version: 'v2.0.0' }], + }); const res = await datasource.getPkgReleases('pkg:go/golang.org/x/text'); expect(res).toMatchSnapshot(); expect(res).not.toBeNull(); -- GitLab