-
Notifications
You must be signed in to change notification settings - Fork 5
🩹 [Patch]: Cleanup of Context usage in classes, and functions for Repository Rule Suites (Insights) #461
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
Conversation
…RepositorySecurityFix function
…epository rule suites
There was a problem hiding this 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 withGitHubContext
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 aliasAlias('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.
}
… for improved readability
…e and list all instances, including comprehensive documentation and examples
…r experience; update related tests for new parameter names and descriptions
…es with detailed assertions
…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.
…se class for improved readability
…GitHubUser for clarity
…te comparison in tests for consistency
…improved flexibility
- 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.
…r correct pagination handling
…ils with pagination support
… for available enterprises
…bOrganizationList function
…d comment out RequiresTwoFactorAuthentication in GitHubOrganization mapping
…thentication mappings in GitHubOrganization
- 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.
Module GitHub - 0.33.7 published to the PowerShell Gallery. |
GitHub release for GitHub v0.33.7 has been created. |
…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
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
withGitHubContext
for improved context management, restructuring properties inGitHubOwner
subclasses, and updating XML format definitions to reflect the new structure.Context Management Updates:
HostName
parameter withGitHubContext
in constructors across multiple classes (GitHubAppInstallation
,GitHubArtifact
,GitHubEnvironment
,GitHubOrganization
). This change centralizes context-related properties, such asHostName
, for better scalability and readability.GitHubOwner Class Restructuring:
Company
,Blog
,Plan
) from theGitHubOwner
class and its subclasses (GitHubEnterprise
,GitHubOrganization
,GitHubUser
). Added new properties such asDescription
andWebsite
to better align with GraphQL schema mappings.GraphQL Mapping Enhancements:
$PropertyToGraphQLMap
hashtables inGitHubEnterprise
andGitHubOrganization
classes to define mappings between class properties and GraphQL fields, improving maintainability and integration with GraphQL APIs.XML Format Updates:
GitHubOwner.Format.ps1xml
file to include new properties (DisplayName
,CreatedAt
) in table views for improved visualization ofGitHubOwner
objects. Removed deprecated columns such asCompany
andPlan
.Type of change
Checklist