Skip to content

Commit

Permalink
Merge pull request #98 from multiformats/master-upgrade
Browse files Browse the repository at this point in the history
upgrade@8022266524
  • Loading branch information
galargh authored Feb 23, 2024
2 parents d4cf920 + 7de9606 commit 16d7a70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 46 deletions.
6 changes: 0 additions & 6 deletions scripts/src/actions/remove-inactive-members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ async function run(): Promise<void> {

const githubRepositoryActivities =
await github.listRepositoryActivities(since)
const githubRepositoryPullRequests =
await github.listRepositoryPullRequests(since)
const githubRepositoryIssues = await github.listRepositoryIssues(since)
const githubRepositoryPullRequestReviewComments =
await github.listRepositoryPullRequestReviewComments(since)
Expand All @@ -72,10 +70,6 @@ async function run(): Promise<void> {
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
Expand Down
57 changes: 17 additions & 40 deletions scripts/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,40 +349,20 @@ 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()
for (const repository of repositories) {
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 16d7a70

Please sign in to comment.