From 7de9606d4da728f4972df81787c0838808bc9979 Mon Sep 17 00:00:00 2001 From: galargh Date: Fri, 23 Feb 2024 16:39:05 +0000 Subject: [PATCH] upgrade@8022266524 --- .../src/actions/remove-inactive-members.ts | 6 -- scripts/src/github.ts | 57 ++++++------------- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/scripts/src/actions/remove-inactive-members.ts b/scripts/src/actions/remove-inactive-members.ts index ba8b44a..8b9a2f1 100644 --- a/scripts/src/actions/remove-inactive-members.ts +++ b/scripts/src/actions/remove-inactive-members.ts @@ -57,8 +57,6 @@ async function run(): Promise { const githubRepositoryActivities = await github.listRepositoryActivities(since) - const githubRepositoryPullRequests = - await github.listRepositoryPullRequests(since) const githubRepositoryIssues = await github.listRepositoryIssues(since) const githubRepositoryPullRequestReviewComments = await github.listRepositoryPullRequestReviewComments(since) @@ -72,10 +70,6 @@ async function run(): Promise { repository: repository.name, actor: activity.actor?.login })), - ...githubRepositoryPullRequests.map(({repository, pullRequest}) => ({ - repository: repository.name, - actor: pullRequest.user?.login - })), ...githubRepositoryIssues.map(({repository, issue}) => ({ repository: repository.name, actor: issue.user?.login diff --git a/scripts/src/github.ts b/scripts/src/github.ts index c931709..a5ae773 100644 --- a/scripts/src/github.ts +++ b/scripts/src/github.ts @@ -349,32 +349,6 @@ export class GitHub { return repositoryActivities } - async listRepositoryPullRequests(since: Date) { - const repositoryPullRequests = [] - const repositories = await this.listRepositories() - for (const repository of repositories) { - core.info(`Listing ${repository.name} pull requests...`) - const pullRequestsIterator = this.client.paginate.iterator( - this.client.pulls.list, - {owner: env.GITHUB_ORG, repo: repository.name, state: 'all'} - ) - for await (const {data: pullRequests} of pullRequestsIterator) { - let shouldContinue = true - for (const pullRequest of pullRequests) { - if (new Date(pullRequest.created_at) < since) { - shouldContinue = false - break - } - repositoryPullRequests.push({repository, pullRequest}) - } - if (!shouldContinue) { - break - } - } - } - return repositoryPullRequests - } - async listRepositoryIssues(since: Date) { const issues = [] const repositories = await this.listRepositories() @@ -382,7 +356,13 @@ export class GitHub { core.info(`Listing ${repository.name} issues...`) const issuesIterator = this.client.paginate.iterator( this.client.issues.listForRepo, - {owner: env.GITHUB_ORG, repo: repository.name, state: 'all'} + { + owner: env.GITHUB_ORG, + repo: repository.name, + state: 'all', + sort: 'created', + direction: 'desc' + } ) for await (const {data: issuesData} of issuesIterator) { let shouldContinue = true @@ -408,7 +388,7 @@ export class GitHub { core.info(`Listing ${repository.name} pull request comments...`) const pullRequestCommentsIterator = this.client.paginate.iterator( this.client.pulls.listReviewCommentsForRepo, - {owner: env.GITHUB_ORG, repo: repository.name} + {owner: env.GITHUB_ORG, repo: repository.name, direction: 'desc'} ) for await (const {data: comments} of pullRequestCommentsIterator) { let shouldContinue = true @@ -434,7 +414,12 @@ export class GitHub { core.info(`Listing ${repository.name} issue comments...`) const issueCommentsIterator = this.client.paginate.iterator( this.client.issues.listCommentsForRepo, - {owner: env.GITHUB_ORG, repo: repository.name} + { + owner: env.GITHUB_ORG, + repo: repository.name, + sort: 'created', + direction: 'desc' + } ) for await (const {data: comments} of issueCommentsIterator) { let shouldContinue = true @@ -458,22 +443,14 @@ export class GitHub { const repositories = await this.listRepositories() for (const repository of repositories) { core.info(`Listing ${repository.name} commit comments...`) - const commitCommentsIterator = this.client.paginate.iterator( + const comments = await this.client.paginate( this.client.repos.listCommitCommentsForRepo, {owner: env.GITHUB_ORG, repo: repository.name} ) - for await (const {data: comments} of commitCommentsIterator) { - let shouldContinue = true - for (const comment of comments) { - if (new Date(comment.created_at) < since) { - shouldContinue = false - break - } + for (const comment of comments) { + if (new Date(comment.created_at) >= since) { commitComments.push({repository, comment}) } - if (!shouldContinue) { - break - } } } return commitComments