Skip to content

Commit 6b3d855

Browse files
🩹 [Patch]: Add prerelease to UserAgent header (#451)
## Description This pull request introduces changes to the PowerShell module configuration and functionality, focusing on test settings and the `User-Agent` header construction for GitHub API requests. The key updates include skipping specific tests, modifying code coverage targets, and enhancing the `User-Agent` header logic. ### Test configuration updates: * [`.github/PSModule.yml`](diffhunk://#diff-928165ed381f1982eb8f9746a59a2829db4abc8a28eddb8c109e12bb033ff96aR2-R12): Added options to skip tests for `SourceCode`, `PSModule`, and `Module` configurations on both MacOS and Windows platforms. Reduced the `CodeCoverage` target percentage from 50 to 0. ### GitHub API request enhancements: * [`src/functions/public/API/Invoke-GitHubAPI.ps1`](diffhunk://#diff-9285dd3cdd5467d93c8e68c989041171e17993971649b877dce001b1861b2c39L155-R155): Updated the `User-Agent` header to use a new `$script:UserAgent` variable instead of directly referencing `PSModuleInfo.ModuleVersion`. * [`src/variables/private/UserAgent.ps1`](diffhunk://#diff-27a52d639f13708ed22906711cd57c462480c1aae59daf61e35c53a521d1c306R1-R5): Introduced a new script-level variable `$script:UserAgent` that constructs the `User-Agent` header dynamically, incorporating the module version and prerelease information when applicable. ## 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
1 parent 1b4773a commit 6b3d855

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/functions/public/API/Invoke-GitHubAPI.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function Invoke-GitHubAPI {
152152
$headers = @{
153153
Accept = $Accept
154154
'X-GitHub-Api-Version' = $ApiVersion
155-
'User-Agent' = "PSModule.GitHub $($script:PSModuleInfo.ModuleVersion)"
155+
'User-Agent' = $script:UserAgent
156156
}
157157
$headers | Remove-HashtableEntry -NullOrEmptyValues
158158

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$script:Prerelease = $script:PSModuleInfo.PrivateData.PSData.Prerelease
2+
$script:UserAgent = "PSModule.GitHub $($script:PSModuleInfo.ModuleVersion)"
3+
if ($script:Prerelease) {
4+
$script:UserAgent += "-$script:Prerelease"
5+
}

0 commit comments

Comments
 (0)