Skip to content

Commit

Permalink
fix: getAuthenticatedOctokit is a standalone method (#5235)
Browse files Browse the repository at this point in the history
fixes
```
TypeError: Cannot read properties of undefined (reading 'getAuthenticatedOctokit')
    at eachInstallation (/usr/src/app/node_modules/gcf-utils/build/src/installations.js:26:32)
    at eachInstallation.next (<anonymous>)
    at GCFBootstrapper.handleScheduledInstallation (/usr/src/app/node_modules/gcf-utils/build/src/gcf-utils.js:492:30)
    at GCFBootstrapper.handleScheduled (/usr/src/app/node_modules/gcf-utils/build/src/gcf-utils.js:447:24)
    at /usr/src/app/node_modules/gcf-utils/build/src/gcf-utils.js:290:32
```
  • Loading branch information
chingor13 authored Sep 26, 2023
1 parent 4666e30 commit 0f95e5a
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 32 deletions.
115 changes: 90 additions & 25 deletions packages/gcf-utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions packages/gcf-utils/src/installations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//

import {WrapConfig} from './configuration';
import {getAuthenticatedOctokit} from './gcf-utils';

// Helper interface to abstract the response of the list installations GitHub response
export interface AppInstallation {
Expand Down Expand Up @@ -49,9 +50,9 @@ export interface InstalledRepository {
export async function* eachInstallation(
wrapConfig: WrapConfig
): AsyncGenerator<AppInstallation, void, void> {
const octokit = await this.getAuthenticatedOctokit(undefined, wrapConfig);
const octokit = await getAuthenticatedOctokit(undefined);
const installationsPaginated = octokit.paginate.iterator(
octokit.apps.listInstallations
octokit.apps.listInstallations as any
);
for await (const response of installationsPaginated) {
for (const installation of response.data) {
Expand All @@ -75,12 +76,9 @@ export async function* eachInstalledRepository(
installationId: number,
wrapConfig: WrapConfig
): AsyncGenerator<InstalledRepository, void, void> {
const octokit = await this.getAuthenticatedOctokit(
installationId,
wrapConfig
);
const octokit = await getAuthenticatedOctokit(installationId);
const installationRepositoriesPaginated = octokit.paginate.iterator(
octokit.apps.listReposAccessibleToInstallation,
octokit.apps.listReposAccessibleToInstallation as any,
{
mediaType: {
previews: ['machine-man'],
Expand Down

0 comments on commit 0f95e5a

Please sign in to comment.