-
Notifications
You must be signed in to change notification settings - Fork 8
🪲 [Fix]: Multi-select custom properties no longer lose individual values #577
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
base: main
Are you sure you want to change the base?
Changes from all commits
378665d
34a7dfe
5434cfe
9b8a0af
ffa1c00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,19 @@ class GitHubCustomProperty { | |
| # The name of the custom property. | ||
| [string] $Name | ||
|
|
||
| # The value of the custom property. | ||
| [string] $Value | ||
| # The value of the custom property. Can be a string or an array of strings for multi-select properties. | ||
| [object] $Value | ||
|
|
||
| GitHubCustomProperty() {} | ||
|
|
||
| GitHubCustomProperty([PSCustomObject] $Object) { | ||
| $this.Name = $Object.property_name ?? $Object.propertyName ?? $Object.Name | ||
| $this.Value = $Object.value ?? $Object.Value | ||
| $rawValue = $Object.value ?? $Object.Value | ||
| if ($rawValue -is [System.Collections.IEnumerable] -and $rawValue -isnot [string]) { | ||
| $this.Value = [string[]]$rawValue | ||
| } else { | ||
| $this.Value = $rawValue | ||
| } | ||
|
Comment on lines
10
to
+17
|
||
| } | ||
|
|
||
| [string] ToString() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,7 +293,7 @@ Describe 'GitHub' { | |
| $stamps.Count | Should -BeGreaterThan 0 | ||
| } | ||
| It 'Get-GitHubStamp - Each stamp has Name and BaseUrl properties' { | ||
| LogGroup "Stamps - Details" { | ||
| LogGroup 'Stamps - Details' { | ||
|
Comment on lines
295
to
+296
|
||
| Get-GitHubStamp | ForEach-Object { | ||
| Write-Host ($_ | Format-List | Out-String) | ||
| $_.Name | Should -Not -BeNullOrEmpty | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -518,6 +518,22 @@ Describe 'Repositories' { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $repos.Count | Should -BeGreaterThan 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| It 'Get-GitHubRepositoryCustomProperty - Gets custom properties and preserves value types' -Skip:($OwnerType -ne 'organization') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LogGroup 'Custom Properties' { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $properties = Get-GitHubRepositoryCustomProperty -Owner $owner -Repository $repoName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host ($properties | Format-List | Out-String) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ($properties) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach ($prop in $properties) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $prop.Name | Should -Not -BeNullOrEmpty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ($prop.Value -is [System.Collections.IEnumerable] -and $prop.Value -isnot [string]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $prop.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.Value.GetType().FullName)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $prop.Value | Should -BeOfType [string] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+528
to
+532
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $prop.Name | Should -Not -BeNullOrEmpty | |
| if ($prop.Value -is [System.Collections.IEnumerable] -and $prop.Value -isnot [string]) { | |
| $prop.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.Value.GetType().FullName)" | |
| } else { | |
| $prop.Value | Should -BeOfType [string] | |
| $prop.property_name | Should -Not -BeNullOrEmpty | |
| if ($prop.value -is [System.Collections.IEnumerable] -and $prop.value -isnot [string]) { | |
| $prop.value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.value.GetType().FullName)" | |
| } else { | |
| $prop.value | Should -BeOfType [string] |
Copilot
AI
May 1, 2026
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.
This test can pass without validating the new behavior: if $properties is empty, there are no assertions, and if all values are scalar strings the array-preservation path is never exercised. To reliably catch regressions, add a deterministic unit test around GitHubCustomProperty([PSCustomObject]) (mocking an array vs scalar value) or otherwise ensure the test repo contains at least one multi-select property and assert it is a [string[]].
| It 'Get-GitHubRepositoryCustomProperty - Gets custom properties and preserves value types' -Skip:($OwnerType -ne 'organization') { | |
| LogGroup 'Custom Properties' { | |
| $properties = Get-GitHubRepositoryCustomProperty -Owner $owner -Repository $repoName | |
| Write-Host ($properties | Format-List | Out-String) | |
| } | |
| if ($properties) { | |
| foreach ($prop in $properties) { | |
| $prop.Name | Should -Not -BeNullOrEmpty | |
| if ($prop.Value -is [System.Collections.IEnumerable] -and $prop.Value -isnot [string]) { | |
| $prop.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.Value.GetType().FullName)" | |
| } else { | |
| $prop.Value | Should -BeOfType [string] | |
| } | |
| It 'GitHubCustomProperty - Preserves scalar and multi-select value types' { | |
| $scalarProperty = [GitHubCustomProperty]::new([PSCustomObject]@{ | |
| name = 'Environment' | |
| value = 'Production' | |
| }) | |
| $arrayProperty = [GitHubCustomProperty]::new([PSCustomObject]@{ | |
| name = 'Regions' | |
| value = @('eu-west-1', 'us-east-1') | |
| }) | |
| $scalarProperty.Name | Should -Be 'Environment' | |
| $scalarProperty.Value | Should -BeOfType [string] | |
| $scalarProperty.Value | Should -Be 'Production' | |
| $arrayProperty.Name | Should -Be 'Regions' | |
| $arrayProperty.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($arrayProperty.Value.GetType().FullName)" | |
| $arrayProperty.Value | Should -Be @('eu-west-1', 'us-east-1') | |
| } | |
| It 'Get-GitHubRepositoryCustomProperty - Gets custom properties and preserves value types' -Skip:($OwnerType -ne 'organization') { | |
| LogGroup 'Custom Properties' { | |
| $properties = Get-GitHubRepositoryCustomProperty -Owner $owner -Repository $repoName | |
| Write-Host ($properties | Format-List | Out-String) | |
| } | |
| $properties | Should -Not -BeNullOrEmpty | |
| foreach ($prop in $properties) { | |
| $prop.Name | Should -Not -BeNullOrEmpty | |
| if ($prop.Value -is [System.Collections.IEnumerable] -and $prop.Value -isnot [string]) { | |
| $prop.Value -is [string[]] | Should -BeTrue -Because "multi-select values must be preserved as string arrays, got: $($prop.Value.GetType().FullName)" | |
| } else { | |
| $prop.Value | Should -BeOfType [string] |
Uh oh!
There was an error while loading. Please reload this page.