From cc5c8f4979ceb6488c8cffc0c7a4c05f7c48969a Mon Sep 17 00:00:00 2001 From: kim5566 Date: Fri, 10 Sep 2021 17:06:25 +1000 Subject: [PATCH 1/3] add paginate Signed-off-by: kim5566 --- .changeset/tidy-shoes-occur.md | 5 +++++ packages/integration/src/github/GithubCredentialsProvider.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/tidy-shoes-occur.md diff --git a/.changeset/tidy-shoes-occur.md b/.changeset/tidy-shoes-occur.md new file mode 100644 index 0000000000..67fa36b672 --- /dev/null +++ b/.changeset/tidy-shoes-occur.md @@ -0,0 +1,5 @@ +--- +'@backstage/integration': patch +--- + +Handle pagination on return results when fetch Github API to list selected repos diff --git a/packages/integration/src/github/GithubCredentialsProvider.ts b/packages/integration/src/github/GithubCredentialsProvider.ts index c7ba6408d9..330187b140 100644 --- a/packages/integration/src/github/GithubCredentialsProvider.ts +++ b/packages/integration/src/github/GithubCredentialsProvider.ts @@ -111,8 +111,8 @@ class GithubAppManager { auth: result.data.token, }); const repos = - await installationClient.apps.listReposAccessibleToInstallation(); - const hasRepo = repos.data.repositories.some(repository => { + await installationClient.paginate(installationClient.apps.listReposAccessibleToInstallation); + const hasRepo = repos && repos.repositories.some(repository => { return repository.name === repo; }); if (!hasRepo) { From 3c78883ba3fc7e9fbba6dde6fda7615367b15cc4 Mon Sep 17 00:00:00 2001 From: kim5566 Date: Fri, 10 Sep 2021 17:55:29 +1000 Subject: [PATCH 2/3] fix formatting and slection of returned results Signed-off-by: kim5566 --- .changeset/clever-months-switch.md | 5 +++++ .../integration/src/github/GithubCredentialsProvider.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/clever-months-switch.md diff --git a/.changeset/clever-months-switch.md b/.changeset/clever-months-switch.md new file mode 100644 index 0000000000..9ffac60f56 --- /dev/null +++ b/.changeset/clever-months-switch.md @@ -0,0 +1,5 @@ +--- +'@backstage/integration': patch +--- + +Handle pagination on return results when fetch GitHub API to list selected repos diff --git a/packages/integration/src/github/GithubCredentialsProvider.ts b/packages/integration/src/github/GithubCredentialsProvider.ts index 330187b140..3156488ba7 100644 --- a/packages/integration/src/github/GithubCredentialsProvider.ts +++ b/packages/integration/src/github/GithubCredentialsProvider.ts @@ -110,9 +110,10 @@ class GithubAppManager { const installationClient = new Octokit({ auth: result.data.token, }); - const repos = - await installationClient.paginate(installationClient.apps.listReposAccessibleToInstallation); - const hasRepo = repos && repos.repositories.some(repository => { + const repos = await installationClient.paginate( + installationClient.apps.listReposAccessibleToInstallation, + ); + const hasRepo = repos.some(repository => { return repository.name === repo; }); if (!hasRepo) { From 63399d41478f9799e46b2681cbc284b02152328f Mon Sep 17 00:00:00 2001 From: kim5566 Date: Fri, 10 Sep 2021 17:58:54 +1000 Subject: [PATCH 3/3] remove duplicate changeset Signed-off-by: kim5566 --- .changeset/clever-months-switch.md | 5 ----- .changeset/tidy-shoes-occur.md | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 .changeset/clever-months-switch.md diff --git a/.changeset/clever-months-switch.md b/.changeset/clever-months-switch.md deleted file mode 100644 index 9ffac60f56..0000000000 --- a/.changeset/clever-months-switch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/integration': patch ---- - -Handle pagination on return results when fetch GitHub API to list selected repos diff --git a/.changeset/tidy-shoes-occur.md b/.changeset/tidy-shoes-occur.md index 67fa36b672..9ffac60f56 100644 --- a/.changeset/tidy-shoes-occur.md +++ b/.changeset/tidy-shoes-occur.md @@ -2,4 +2,4 @@ '@backstage/integration': patch --- -Handle pagination on return results when fetch Github API to list selected repos +Handle pagination on return results when fetch GitHub API to list selected repos