From dc9125e4a31f598cc54d8b3c708a8c959ae39f9a Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Mon, 11 Jun 2018 11:30:28 +0200 Subject: [PATCH] refactor: add gitRef to github datasource --- lib/datasource/github.js | 9 ++++----- .../datasource/__snapshots__/github.spec.js.snap | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/datasource/github.js b/lib/datasource/github.js index 7363084473..3bbceb9d40 100644 --- a/lib/datasource/github.js +++ b/lib/datasource/github.js @@ -50,16 +50,15 @@ async function getDependency(purl, config) { const { isVersion, sortVersions } = versioning(versionScheme); // Return a sorted list of valid Versions versions = versions.filter(isVersion).sort(sortVersions); - // Return sanitized versions (e.g. without leading 'v') if configured - if (options.sanitize === 'true') { - versions = versions.map(isVersion); - } const dependency = { repositoryUrl: 'https://github.com/' + repo, versions: {}, }; versions.forEach(version => { - dependency.versions[version] = {}; + const v = options.sanitize === 'true' ? isVersion(version) : version; + dependency.versions[v] = { + gitRef: version, + }; }); return dependency; } diff --git a/test/datasource/__snapshots__/github.spec.js.snap b/test/datasource/__snapshots__/github.spec.js.snap index ecd57d7b77..fa56ea87e2 100644 --- a/test/datasource/__snapshots__/github.spec.js.snap +++ b/test/datasource/__snapshots__/github.spec.js.snap @@ -4,8 +4,12 @@ exports[`datasource/github getDependency returns cleaned tags 1`] = ` Object { "repositoryUrl": "https://github.com/some/dep", "versions": Object { - "1.0.0": Object {}, - "1.1.0": Object {}, + "1.0.0": Object { + "gitRef": "1.0.0", + }, + "1.1.0": Object { + "gitRef": "v1.1.0", + }, }, } `; @@ -14,8 +18,12 @@ exports[`datasource/github getDependency returns releases 1`] = ` Object { "repositoryUrl": "https://github.com/some/dep", "versions": Object { - "1.0.0": Object {}, - "v1.1.0": Object {}, + "1.0.0": Object { + "gitRef": "1.0.0", + }, + "v1.1.0": Object { + "gitRef": "v1.1.0", + }, }, } `; -- GitLab