Skip to content

fix: Re-enable creation of the new repositories #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main-enterprise
Choose a base branch
from

Conversation

strainovic
Copy link

Hi all,

This PR fixes issue safe-settings/issues/780.

The code that returns the list of all repositories does not include one that does not exist.

Cheers! 👋

@Copilot Copilot AI review requested due to automatic review settings May 23, 2025 15:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the repository-fetch logic to include repos defined in the config but missing from the API response.

  • Introduces tracking of processed repos to avoid duplicates
  • Splits processing into existing and missing repos batches
  • Concatenates and filters both result sets before returning

@klutchell
Copy link
Contributor

This change still requires force_create: true, correct? Just making sure that repo creation is still opt-in and not the default behaviour.

@strainovic
Copy link
Author

Hi @klutchell.

Yes, it requires force_create: true. It is here:

if (this.force_create) {

Thanks

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

A fix to ensure newly configured repositories that aren’t returned by the installation API still get processed.

  • Split repository handling into “existing” (via GitHub paginate) and “missing” (from configuration) batches
  • Track which repos have been processed to avoid duplicates
  • Concatenate results from both batches and filter out nulls
Comments suppressed due to low confidence (1)

lib/settings.js:508

  • [nitpick] Rename repoInConfigs to something like configuredRepos or reposFromConfig to more clearly express its purpose.
const repoInConfigs = Object.values(this.repoConfigs)

Comment on lines +492 to +493
const results = []

Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The results array is declared but never populated; remove it and simplify the return to directly combine existingRepoResults and missingRepoResults.

Suggested change
const results = []

Copilot uses AI. Check for mistakes.

Comment on lines +495 to +505
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 })
}))
})
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid mixing await with .then; instead, do const repositories = await github.paginate(...) and then const existingRepoResults = await Promise.all(...) for clarity.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants