From ecb81eff39de682b14c5eabc3b8ae67ba15acbd6 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Sat, 2 Jun 2018 17:07:15 +0200 Subject: [PATCH] fix: disable ghe token when looking up git datasource --- lib/datasource/github.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/datasource/github.js b/lib/datasource/github.js index edef25e76d..518612cd74 100644 --- a/lib/datasource/github.js +++ b/lib/datasource/github.js @@ -9,6 +9,16 @@ async function getDependency(repo, options = {}) { const ref = options.ref || 'tag'; const clean = options.clean === 'true'; let versions; + let endpoint; + let token; + // istanbul ignore if + if (process.env.GITHUB_ENDPOINT) { + logger.debug('Removing GHE token before retrieving node releases'); + endpoint = process.env.GITHUB_ENDPOINT; + delete process.env.GITHUB_ENDPOINT; + token = process.env.GITHUB_TOKEN; + process.env.GITHUB_TOKEN = process.env.GITHUB_COM_TOKEN; + } try { if (ref === 'tag') { const url = `repos/${repo}/git/refs/tags?per_page=100`; @@ -27,6 +37,13 @@ async function getDependency(repo, options = {}) { { repo, err, message: err.message }, 'Error retrieving from github' ); + } finally { + // istanbul ignore if + if (endpoint) { + logger.debug('Restoring GHE token and endpoint'); + process.env.GITHUB_TOKEN = token; + process.env.GITHUB_ENDPOINT = endpoint; + } } if (!versions) { return null; -- GitLab