From e4dd51d9b48cad4e34798bc51f9a4fd064a2a470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nenad=20Strainovi=C4=87?= Date: Fri, 23 May 2025 17:26:49 +0200 Subject: [PATCH 1/3] fix: Re-enable creation of the new repositories --- lib/settings.js | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/lib/settings.js b/lib/settings.js index 20e71167..ce2e1ab3 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -488,17 +488,46 @@ ${this.results.reduce((x, y) => { async eachRepositoryRepos (github, log) { log.debug('Fetching repositories') - return github.paginate('GET /installation/repositories').then(repositories => { - return Promise.all(repositories.map(repository => { - if (this.isRestricted(repository.name)) { - return null - } + const processedRepos = new Set() + const results = [] + + // Process existing repositories + const existingRepoResults = await github.paginate('GET /installation/repositories') + .then(repositories => { + return Promise.all(repositories.map(repository => { + if (this.isRestricted(repository.name)) { + return null + } + const { owner, name } = repository + processedRepos.add(`${owner.login}/${name}`) + return this.updateRepos({ owner: owner.login, repo: name }) + })) + }) - const { owner, name } = repository - return this.updateRepos({ owner: owner.login, repo: name }) + // Process missing repositories + const repoInConfigs = Object.values(this.repoConfigs) + .filter(config => config.repository?.name) + .map(config => { + return { + name: config.repository.name, + owner: config.repository.organization || this.repo.owner + } }) - ) - }) + const missingRepoResults = await Promise.all( + repoInConfigs + .filter(repo => !this.isRestricted(repo.name)) + .filter(repo => !processedRepos.has(`${repo.owner}/${repo.name}`)) + .map(repo => { + processedRepos.add(`${repo.owner}/${repo.name}`) + return this.updateRepos({ owner: repo.owner, repo: repo.name }) + }) + ) + + results + .concat(existingRepoResults || [], missingRepoResults || []) + .filter(result => result !== null) + + return results } /** From 70441d20e632af429470ea08317b45a70d860f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nenad=20Strainovi=C4=87?= Date: Fri, 23 May 2025 17:37:33 +0200 Subject: [PATCH 2/3] Update lib/settings.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lib/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/settings.js b/lib/settings.js index ce2e1ab3..6f9647e2 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -523,7 +523,7 @@ ${this.results.reduce((x, y) => { }) ) - results + results = results .concat(existingRepoResults || [], missingRepoResults || []) .filter(result => result !== null) From dc3f58c3fa5156a12975188effa5a30901db9a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nenad=20Strainovi=C4=87?= Date: Fri, 23 May 2025 17:42:31 +0200 Subject: [PATCH 3/3] Optimize return results --- lib/settings.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/settings.js b/lib/settings.js index 6f9647e2..c5b48ccd 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -523,11 +523,9 @@ ${this.results.reduce((x, y) => { }) ) - results = results + return results .concat(existingRepoResults || [], missingRepoResults || []) .filter(result => result !== null) - - return results } /**