Skip to content

Commit e4dd51d

Browse files
committed
fix: Re-enable creation of the new repositories
1 parent fbdb673 commit e4dd51d

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

lib/settings.js

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,17 +488,46 @@ ${this.results.reduce((x, y) => {
488488

489489
async eachRepositoryRepos (github, log) {
490490
log.debug('Fetching repositories')
491-
return github.paginate('GET /installation/repositories').then(repositories => {
492-
return Promise.all(repositories.map(repository => {
493-
if (this.isRestricted(repository.name)) {
494-
return null
495-
}
491+
const processedRepos = new Set()
492+
const results = []
493+
494+
// Process existing repositories
495+
const existingRepoResults = await github.paginate('GET /installation/repositories')
496+
.then(repositories => {
497+
return Promise.all(repositories.map(repository => {
498+
if (this.isRestricted(repository.name)) {
499+
return null
500+
}
501+
const { owner, name } = repository
502+
processedRepos.add(`${owner.login}/${name}`)
503+
return this.updateRepos({ owner: owner.login, repo: name })
504+
}))
505+
})
496506

497-
const { owner, name } = repository
498-
return this.updateRepos({ owner: owner.login, repo: name })
507+
// Process missing repositories
508+
const repoInConfigs = Object.values(this.repoConfigs)
509+
.filter(config => config.repository?.name)
510+
.map(config => {
511+
return {
512+
name: config.repository.name,
513+
owner: config.repository.organization || this.repo.owner
514+
}
499515
})
500-
)
501-
})
516+
const missingRepoResults = await Promise.all(
517+
repoInConfigs
518+
.filter(repo => !this.isRestricted(repo.name))
519+
.filter(repo => !processedRepos.has(`${repo.owner}/${repo.name}`))
520+
.map(repo => {
521+
processedRepos.add(`${repo.owner}/${repo.name}`)
522+
return this.updateRepos({ owner: repo.owner, repo: repo.name })
523+
})
524+
)
525+
526+
results
527+
.concat(existingRepoResults || [], missingRepoResults || [])
528+
.filter(result => result !== null)
529+
530+
return results
502531
}
503532

504533
/**

0 commit comments

Comments
 (0)