Skip to content

Conversation

@MariusStorhaug
Copy link
Member

@MariusStorhaug MariusStorhaug commented Jun 7, 2025

Description

This pull request updates the GitHub module to improve context management by introducing a ContextVault parameter and upgrading module dependencies. The most significant changes include adding the ContextVault parameter to context-related functions, updating the required module versions, and modifying the default configuration structure. As a result of these changes, the Anonymous evaluation and default context resolution is changed.

Context Management Updates

  • Added the ContextVault parameter to Set-Context and Get-Context calls across multiple functions, ensuring context data is stored and retrieved from the specified vault ($script:GitHub.ContextVault).
  • Introduced a new ContextVault property in the $script:GitHub object to centralize vault configuration.

Dependency Updates

  • Context module from version 7.0.2 to 8.0.2
  • Sodium module from version 2.1.2 to 2.2.0

Context resolution

  • Moved the Anonymous and default context resolution to the Resolve-GitHubContext function to streamline context retrieval.

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 Jun 7, 2025
Copilot AI review requested due to automatic review settings June 7, 2025 19:46
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner June 7, 2025 19:46

This comment was marked as outdated.

@MariusStorhaug MariusStorhaug requested a review from Copilot June 8, 2025 10:17
Copy link
Contributor

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 updates dependency versions and enhances context handling by introducing a ContextVault parameter, adjusting default configuration, and adding separators in test teardown.

  • Added ContextVault parameter to all Set-Context/Get-Context calls and a new ContextVault property in $script:GitHub.
  • Bumped Context module requirement to 8.0.0 and Sodium to 2.2.0 across scripts.
  • Changed default config ID from 'PSModule.GitHub' to a shorter 'Module' and added visual separators in test AfterAll blocks.

Reviewed Changes

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

Show a summary per file
File Description
tests/TEMPLATE.ps1 Added Write-Host separator after disconnect
tests/Secrets.Tests.ps1 Added Write-Host separator after disconnect
tests/Repositories.Tests.ps1 Added Write-Host separator after disconnect
tests/Releases.Tests.ps1 Added Write-Host separator after disconnect
tests/Organizations.Tests.ps1 Added Write-Host separator after disconnect
tests/GitHub.Tests.ps1 Added Write-Host separator after multiple AfterAll blocks
tests/Environments.Tests.ps1 Added Write-Host separator after disconnect
tests/Artifacts.Tests.ps1 Added Write-Host separator after disconnect
src/variables/private/GitHub.ps1 Introduced ContextVault, updated default ID
src/functions/public/Secrets/Set-GitHubSecret.ps1 Removed top #Requires, added bottom #Requires for Sodium
src/functions/public/Config/Set-GitHubConfig.ps1 Updated Set-Context calls to include -Vault
src/functions/public/Config/Remove-GitHubConfig.ps1 Updated Set-Context calls to include -Vault
src/functions/public/Config/Get-GitHubConfig.ps1 Replaced direct config return with Get-Context -Vault
src/functions/public/Auth/Context/Get-GitHubContext.ps1 Updated Get-Context calls, simplified ID construction
src/functions/public/Auth/Connect-GitHubAccount.ps1 Streamed verbose output via Format-* -Stream
src/functions/private/Config/Initialize-GitHubConfig.ps1 Updated Get-Context/Set-Context to include -Vault
src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 Added -Vault to Set-Context
src/functions/private/Auth/Context/Set-GitHubContext.ps1 Updated Set-Context to include -Vault, removed prefixed ID
src/functions/private/Auth/Context/Remove-GitHubContext.ps1 Updated Remove-Context to include -Vault, removed prefix
examples/Connecting.ps1 Bumped #Requires directive for Context module
Comments suppressed due to low confidence (5)

src/functions/public/Secrets/Set-GitHubSecret.ps1:146

  • PowerShell #Requires directives must appear before any script code to be effective. Move this directive to the top of the file, before the function definition.
#Requires -Modules @{ ModuleName = 'Sodium'; RequiredVersion = '2.2.0' }

src/variables/private/GitHub.ps1:6

  • [nitpick] The default config ID 'Module' is very generic and could collide with other modules. Consider a more descriptive identifier like 'GitHubModule' or retain 'PSModule.GitHub'.
ID                            = 'Module'

src/functions/public/Config/Get-GitHubConfig.ps1:33

  • Excluding the ID property may break consumers that expect it on the returned object. Consider retaining the ID or documenting that it is intentionally removed.
Get-Context -ID $script:GitHub.Config.ID -Vault $script:GitHub.ContextVault | Select-Object -ExcludeProperty ID

src/functions/private/Auth/Context/Remove-GitHubContext.ps1:39

  • The ID passed to Remove-Context is just the context name, but stored contexts include the module namespace. Use the full ID (e.g., "$($script:GitHub.Config.ID)/$Context") to ensure the correct vault entry is removed.
Remove-Context -ID $Context -Vault $script:GitHub.ContextVault

src/functions/private/Auth/Context/Set-GitHubContext.ps1:145

  • Storing contexts by name only may overwrite or collide entries if multiple modules share a vault. Prefix the ID with the module namespace (e.g., "$($script:GitHub.Config.ID)/$($contextObj['Name'])").
Set-Context -ID $($contextObj['Name']) -Context $contextObj -Vault $script:GitHub.ContextVault

…d Connect-GitHubApp for improved output formatting; correct warning message in Disconnect-GitHubAccount
…ect-GitHubApp by adding -Debug and -Verbose flags
…iple scripts for consistency; add -PassThru parameter to Set-Context calls for improved functionality
…and Invoke-GitHubAPI for enhanced debugging output
… in Get-GitHubLicense for improved readability
…racters before function and filter declarations across multiple files.
… in Get-GitHubContext for improved output visibility
…Set-GitHubContext and Get-GitHubContext for improved visibility
…n Set-GitHubContext for improved output visibility
…Set-GitHubContext for improved debugging visibility
…Name, Get-GitHubLicenseList, and Get-GitHubRepositoryLicense functions for cleaner code

🩹 [Patch]: Replace Write-Host with Write-Debug for context output in Get-GitHubContext for improved debugging visibility
…ByName and Get-GitHubGitignoreList functions for cleaner code
…I call and adjust output formatting in Get-GitHubRateLimit for consistency
…HubContext; enhance context handling in Resolve-GitHubContext for 'Anonymous' cases
…rove error handling and streamline checks for 'Anonymous' AuthType
…ymous' GitHubContext object with verbose logging
…racePeriodInHours, PerPage, RetryCount, RetryInterval, and JwtTimeTolerance; modify Invoke-GitHubAPI to check Context.Name for 'Anonymous'
@MariusStorhaug MariusStorhaug merged commit 31e17d6 into main Jun 9, 2025
10 checks passed
@MariusStorhaug MariusStorhaug deleted the contextbump branch June 9, 2025 16:58
@github-project-automation github-project-automation bot moved this from Todo to Done in GitHub PowerShell Module Jun 9, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2025

Module GitHub - 0.29.3 published to the PowerShell Gallery.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2025

GitHub release for GitHub v0.29.3 has been created.

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.

1 participant