Skip to content

Conversation

MariusStorhaug
Copy link
Member

@MariusStorhaug MariusStorhaug commented Jul 5, 2025

Description

This pull request introduces several changes across multiple files to enhance the functionality and structure of GitHub-related classes in the codebase. The most notable updates include replacing HostName with GitHubContext for improved context management, restructuring properties in GitHubOwner subclasses, and updating XML format definitions to reflect the new structure.

Context Management Updates:

  • Replaced the HostName parameter with GitHubContext in constructors across multiple classes (GitHubAppInstallation, GitHubArtifact, GitHubEnvironment, GitHubOrganization). This change centralizes context-related properties, such as HostName, for better scalability and readability.

GitHubOwner Class Restructuring:

  • Removed redundant properties (e.g., Company, Blog, Plan) from the GitHubOwner class and its subclasses (GitHubEnterprise, GitHubOrganization, GitHubUser). Added new properties such as Description and Website to better align with GraphQL schema mappings.

GraphQL Mapping Enhancements:

  • Introduced static $PropertyToGraphQLMap hashtables in GitHubEnterprise and GitHubOrganization classes to define mappings between class properties and GraphQL fields, improving maintainability and integration with GraphQL APIs.

XML Format Updates:

  • Updated the GitHubOwner.Format.ps1xml file to include new properties (DisplayName, CreatedAt) in table views for improved visualization of GitHubOwner objects. Removed deprecated columns such as Company and Plan.

Type of change

  • 📖 [Docs]
  • 🪲 [Fix]
  • 🩹 [Patch]
  • ⚠️ [Security fix]
  • 🚀 [Feature]
  • 🌟 [Breaking change]

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@MariusStorhaug MariusStorhaug self-assigned this Jul 5, 2025
@Copilot Copilot AI review requested due to automatic review settings July 5, 2025 05:56
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner July 5, 2025 05:56
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 patch refactors classes and functions to replace direct HostName parameters with a GitHubContext object for URL construction and removes several unused aliases and annotations.

  • Replaced HostName parameters with GitHubContext in constructors and function calls
  • Removed unused [Alias(...)] declarations and outdated comments
  • Simplified attribute formatting for diagnostics suppressions

Reviewed Changes

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

Show a summary per file
File Description
src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 Removed unused Alias('org') from $Owner parameter
src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 Removed unused function alias
src/functions/public/Environments/Set-GitHubEnvironment.ps1 Updated GitHubEnvironment instantiation to accept GitHubContext
src/functions/public/Auth/Connect-GitHubApp.ps1 Changed New-GitHubAppInstallationAccessToken parameter from InstallationID to ID
src/functions/private/Users/Get-GitHubUserByName.ps1 Updated GitHubOrganization constructor to accept GitHubContext
src/functions/private/Users/Get-GitHubMyUser.ps1 Updated GitHubOrganization constructor to accept GitHubContext
src/functions/private/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 Removed unused aliases and a skip-test comment
src/functions/private/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 Removed unused aliases and a skip-test comment
src/functions/private/Organization/Get-GitHubUserOrganization.ps1 Updated GitHubOrganization constructor to accept GitHubContext
src/functions/private/Organization/Get-GitHubMyOrganization.ps1 Updated GitHubOrganization constructor to accept GitHubContext
src/functions/private/Organization/Get-GitHubAllOrganization.ps1 Updated GitHubOrganization constructor to accept GitHubContext
src/functions/private/Environments/Get-GitHubEnvironmentList.ps1 Updated GitHubEnvironment instantiation to accept GitHubContext
src/functions/private/Environments/Get-GitHubEnvironmentByName.ps1 Removed unused aliases and updated GitHubEnvironment instantiation
src/functions/private/Auth/Context/Remove-GitHubContext.ps1 Removed unused Alias('Name') from $Context parameter
src/functions/private/Artifacts/Get-GitHubArtifactFromWorkflowRun.ps1 Updated GitHubArtifact instantiation to accept GitHubContext
src/functions/private/Artifacts/Get-GitHubArtifactFromRepository.ps1 Updated GitHubArtifact instantiation to accept GitHubContext
src/functions/private/Artifacts/Get-GitHubArtifactById.ps1 Updated GitHubArtifact instantiation to accept GitHubContext
src/functions/private/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 Reformatted suppress attribute and updated $ID parameter signature
src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 Updated GitHubAppInstallation to accept GitHubContext
src/functions/private/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 Removed unused function alias
src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 Updated GitHubOrganization instantiation to accept GitHubContext
src/classes/public/Owner/GitHubOwner/GitHubOrganization.ps1 Updated constructor signature and URL generation using Context.HostName
src/classes/public/Environment/GitHubEnvironment.ps1 Updated constructor signature and URL generation using Context.HostName
src/classes/public/Artifacts/GitHubArtifact.ps1 Updated constructor signature and URL generation using Context.HostName
src/classes/public/App/GitHubAppInstallation.ps1 Updated constructor signature and URL generation using Context.HostName
Comments suppressed due to low confidence (3)

src/functions/public/Auth/Connect-GitHubApp.ps1:125

  • Changing the parameter from -InstallationID to -ID is a breaking change for existing scripts. Consider adding an alias Alias('InstallationID') to the $ID parameter to maintain backward compatibility.
            $token = New-GitHubAppInstallationAccessToken -Context $Context -ID $installation.id

src/functions/private/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1:37

  • The removal of the Get-GitHubAppJWT alias could break existing automation that relies on it. Consider restoring the alias or providing a clear deprecation notice.
    )]

src/functions/private/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1:104

  • This function is marked to skip tests and currently lacks coverage. Please add automated tests for this behavior to ensure future changes are validated.
}

…e and list all instances, including comprehensive documentation and examples
…r experience; update related tests for new parameter names and descriptions
…each loops for improved readability; update Update-GitHubOrganization to pass context parameter correctly; clean up test logging in Enterprise.Tests
…Get-GitHubEnterpriseList to use .Values for improved clarity; add suppress message attributes for variable scoping issues.
- Created TEMPLATE.ps1 for structuring Pester tests with authentication cases.
- Implemented Teams.Tests.ps1 to test GitHub Teams API functionalities, including team creation, retrieval, updating, and deletion.
- Developed Users.Tests.ps1 to validate user-related API calls, such as fetching user details and managing user emails.
- Established Variables.Tests.ps1 for testing GitHub repository and organization variable management, including setting, updating, and removing variables.
- Added necessary suppressions for Pester-related warnings and ensured proper logging for debugging.
…d comment out RequiresTwoFactorAuthentication in GitHubOrganization mapping
- Created TEMPLATE.ps1 for Pester testing framework setup.
- Added Teams.Tests.ps1 to test GitHub Teams API functionalities.
- Introduced Users.Tests.ps1 for testing user-related API endpoints.
- Implemented Variables.Tests.ps1 to validate GitHub variable management.
- Each test file includes necessary setup, teardown, and context-specific tests.
@MariusStorhaug MariusStorhaug merged commit 7baaed8 into main Jul 6, 2025
11 checks passed
@MariusStorhaug MariusStorhaug deleted the rules branch July 6, 2025 19:38
@github-project-automation github-project-automation bot moved this from Todo to Done in GitHub PowerShell Module Jul 6, 2025
Copy link
Contributor

github-actions bot commented Jul 6, 2025

Module GitHub - 0.33.7 published to the PowerShell Gallery.

Copy link
Contributor

github-actions bot commented Jul 6, 2025

GitHub release for GitHub v0.33.7 has been created.

MariusStorhaug added a commit that referenced this pull request Jul 6, 2025
…ository Rule Suites (Insights) (#461)

## Description

This pull request introduces several changes across multiple files to
enhance the functionality and structure of GitHub-related classes in the
codebase. The most notable updates include replacing `HostName` with
`GitHubContext` for improved context management, restructuring
properties in `GitHubOwner` subclasses, and updating XML format
definitions to reflect the new structure.

- Fixes #454

### Context Management Updates:
* Replaced the `HostName` parameter with `GitHubContext` in constructors
across multiple classes (`GitHubAppInstallation`, `GitHubArtifact`,
`GitHubEnvironment`, `GitHubOrganization`). This change centralizes
context-related properties, such as `HostName`, for better scalability
and readability.

### GitHubOwner Class Restructuring:
* Removed redundant properties (e.g., `Company`, `Blog`, `Plan`) from
the `GitHubOwner` class and its subclasses (`GitHubEnterprise`,
`GitHubOrganization`, `GitHubUser`). Added new properties such as
`Description` and `Website` to better align with GraphQL schema
mappings.

### GraphQL Mapping Enhancements:
* Introduced static `$PropertyToGraphQLMap` hashtables in
`GitHubEnterprise` and `GitHubOrganization` classes to define mappings
between class properties and GraphQL fields, improving maintainability
and integration with GraphQL APIs.

### XML Format Updates:
* Updated the `GitHubOwner.Format.ps1xml` file to include new properties
(`DisplayName`, `CreatedAt`) in table views for improved visualization
of `GitHubOwner` objects. Removed deprecated columns such as `Company`
and `Plan`.

## Type of change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [x] 🩹 [Patch]
- [ ] ⚠️ [Security fix]
- [ ] 🚀 [Feature]
- [ ] 🌟 [Breaking change]

## Checklist

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🩹 [Patch]: Convert some of the org functions to GraphQL

1 participant