Skip to content

Add better handling for suborgproperties and suborgteams #1031

Open
avelizmu wants to merge 1 commit into
github-community-projects:main-enterprisefrom
avelizmu:main-enterprise
Open

Add better handling for suborgproperties and suborgteams #1031
avelizmu wants to merge 1 commit into
github-community-projects:main-enterprisefrom
avelizmu:main-enterprise

Conversation

@avelizmu

Copy link
Copy Markdown
Contributor

Essentially changing the handling for suborgproperties and suborgteams when only checking a single repo (in the event of a webhook like repo.created or any other that target a specific repo), so that the API requests don't scale with the number of files that have suborgproperties or suborgteams defined.


AI Overview:

This pull request introduces a repo-scoped optimization for resolving suborg config membership in lib/settings.js, significantly improving performance when syncing a single repository. Instead of making organization-wide API calls to enumerate all repos, teams, and properties for all suborgs, the new approach inspects only the relevant repository's teams and custom properties. Comprehensive unit tests are added to verify this behavior.

Repo-scoped suborg config resolution:

  • Added a new method getSubOrgConfigsForRepo to efficiently resolve suborg config membership for a single repo by checking only that repo's teams and custom properties, minimizing API calls (lib/settings.js).
  • Updated getSubOrgConfigs and its callers (loadConfigs, updateRepos) to use the new repo-scoped logic when appropriate (lib/settings.js). [1] [2] [3]
  • Implemented helper methods getReposTeams and getRepoCustomPropertyValues to fetch a repo's teams and custom property values, respectively (lib/settings.js).
  • Added the repoMatchesProperties helper to match repo properties against suborg config filters, handling type coercion and case-insensitive property names (lib/settings.js).

Testing:

  • Added a comprehensive test suite for repo-scoped suborg config resolution and property matching, ensuring correct behavior and minimal API usage (test/unit/lib/settings.test.js).

Copilot AI review requested due to automatic review settings July 15, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request optimizes suborg membership resolution when syncing a single repository by using repo-scoped queries for team membership and custom property values, avoiding org-wide enumeration that scales with the number of suborg configs.

Changes:

  • Added a repo-scoped suborg resolution path (getSubOrgConfigsForRepo) and wired getSubOrgConfigs(repo) into single-repo sync flows to reduce API fan-out.
  • Introduced helper methods to fetch a repo’s teams and custom property values, plus a local matcher (repoMatchesProperties) for property-based suborg filters.
  • Added unit tests covering repo-scoped suborg resolution behavior and property matching/coercion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/settings.js Adds repo-scoped suborg config resolution and helpers to minimize API calls during single-repo syncs.
test/unit/lib/settings.test.js Adds unit coverage for repo-scoped suborg membership resolution and custom property matching behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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