From dc143eb4e59c510f45dabfb4958fd17cb75e24ab Mon Sep 17 00:00:00 2001
From: Ayoub Kaanich <kayoub5@live.com>
Date: Mon, 11 Jun 2018 06:50:09 +0200
Subject: [PATCH] fix: use better tag endpoint for github datasource

---
 lib/datasource/github.js       | 7 ++-----
 test/datasource/github.spec.js | 8 ++++----
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/datasource/github.js b/lib/datasource/github.js
index 2ce70a4368..ddc3caa7e1 100644
--- a/lib/datasource/github.js
+++ b/lib/datasource/github.js
@@ -25,11 +25,8 @@ async function getDependency(purl) {
       );
     } else {
       // tag
-      const url = `repos/${repo}/git/refs/tags?per_page=100`;
-      const tagPrefix = 'refs/tags/';
-      versions = (await ghGot(url, { paginate: true })).body
-        .filter(o => o.ref && o.ref.startsWith(tagPrefix))
-        .map(o => o.ref.replace(tagPrefix, ''));
+      const url = `repos/${repo}/tags?per_page=100`;
+      versions = (await ghGot(url, { paginate: true })).body.map(o => o.name);
     }
   } catch (err) {
     logger.info(
diff --git a/test/datasource/github.spec.js b/test/datasource/github.spec.js
index 7f80095c73..5e92ede6da 100644
--- a/test/datasource/github.spec.js
+++ b/test/datasource/github.spec.js
@@ -8,10 +8,10 @@ describe('datasource/github', () => {
   describe('getDependency', () => {
     it('returns cleaned tags', async () => {
       const body = [
-        { ref: 'refs/tags/a' },
-        { ref: 'refs/tags/v' },
-        { ref: 'refs/tags/1.0.0' },
-        { ref: 'refs/tags/v1.1.0' },
+        { name: 'a' },
+        { name: 'v' },
+        { name: '1.0.0' },
+        { name: 'v1.1.0' },
       ];
       ghGot.mockReturnValueOnce({ headers: {}, body });
       const res = await datasource.getDependency(
-- 
GitLab