From ca3a1c9f9dd5c38cd39a55fe5893de57609adff3 Mon Sep 17 00:00:00 2001
From: Hutson Betts <destroyerofbuilds@users.noreply.github.com>
Date: Mon, 20 Nov 2017 13:36:40 -0600
Subject: [PATCH] fix(github): paginate repo get requests (#1193)

Enable pagainate for requests made to the `user/repos` endpoint
for fetching all repositories the configured user has access to.
---
 lib/platform/github/index.js                          | 2 +-
 test/config/index.spec.js                             | 3 +++
 test/platform/github/__snapshots__/index.spec.js.snap | 6 ++++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js
index 350e20aa56..accafdee80 100644
--- a/lib/platform/github/index.js
+++ b/lib/platform/github/index.js
@@ -53,7 +53,7 @@ async function getRepos(token, endpoint) {
     process.env.GITHUB_ENDPOINT = endpoint;
   }
   try {
-    const res = await get('user/repos');
+    const res = await get('user/repos', { paginate: true });
     return res.body.map(repo => repo.full_name);
   } catch (err) /* istanbul ignore next */ {
     logger.error({ err }, `GitHub getRepos error`);
diff --git a/test/config/index.spec.js b/test/config/index.spec.js
index 869b7d4de7..b8d06b5581 100644
--- a/test/config/index.spec.js
+++ b/test/config/index.spec.js
@@ -76,6 +76,7 @@ describe('config/index', () => {
       const env = {};
       defaultArgv = defaultArgv.concat(['--autodiscover', '--token=abc']);
       ghGot.mockImplementationOnce(() => ({
+        headers: {},
         body: [
           {
             full_name: 'a/b',
@@ -145,6 +146,7 @@ describe('config/index', () => {
       const env = { GITHUB_TOKEN: 'abc' };
       defaultArgv = defaultArgv.concat(['--autodiscover']);
       ghGot.mockImplementationOnce(() => ({
+        headers: {},
         body: [],
       }));
       await configParser.parseConfigs(env, defaultArgv);
@@ -155,6 +157,7 @@ describe('config/index', () => {
       const env = { GITHUB_TOKEN: 'abc', RENOVATE_LOG_FILE: 'debug.log' };
       defaultArgv = defaultArgv.concat(['--autodiscover']);
       ghGot.mockImplementationOnce(() => ({
+        headers: {},
         body: [],
       }));
       await configParser.parseConfigs(env, defaultArgv);
diff --git a/test/platform/github/__snapshots__/index.spec.js.snap b/test/platform/github/__snapshots__/index.spec.js.snap
index 1bd4e7c2a8..f0c748b5cd 100644
--- a/test/platform/github/__snapshots__/index.spec.js.snap
+++ b/test/platform/github/__snapshots__/index.spec.js.snap
@@ -519,6 +519,9 @@ exports[`platform/github getRepos should return an array of repos 1`] = `
 Array [
   Array [
     "user/repos",
+    Object {
+      "paginate": true,
+    },
   ],
 ]
 `;
@@ -534,6 +537,9 @@ exports[`platform/github getRepos should support a custom endpoint 1`] = `
 Array [
   Array [
     "user/repos",
+    Object {
+      "paginate": true,
+    },
   ],
 ]
 `;
-- 
GitLab