Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions GitHubCore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,15 @@ function Invoke-GHRestMethod

if (-not (Get-GitHubConfiguration -Name DisableSmarterObjects))
{
$finalResult = ConvertTo-SmarterObject -InputObject $finalResult
# In the case of getting raw content from the repo, we'll end up with a large object/byte
# array which isn't convertible to a smarter object, but by _trying_ we'll end up wasting
# a lot of time. Let's optimize here by not bothering to send in something that we
# know is definitely not convertible ([int32] on PS5, [long] on PS7).
if (($finalResult -isnot [Object[]]) -or
(($finalResult.Count -gt 0) -and ($finalResult[0] -isnot [int]) -and ($finalResult[0] -isnot [long])))
{
$finalResult = ConvertTo-SmarterObject -InputObject $finalResult
}
}

$links = $result.Headers['Link'] -split ','
Expand Down Expand Up @@ -900,7 +908,13 @@ filter ConvertTo-SmarterObject
return $null
}

if ($InputObject -is [System.Collections.IList])
if (($InputObject -is [int]) -or ($InputObject -is [long]))
{
# In some instances, an int/long was being seen as a [PSCustomObject].
# This attempts to short-circuit extra work we would have done had that happened.
Write-Output -InputObject $InputObject
}
elseif ($InputObject -is [System.Collections.IList])
{
$InputObject |
ConvertTo-SmarterObject |
Expand Down
1 change: 0 additions & 1 deletion Tests/GitHubAnalytics.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ try
for ($i = 0; $i -lt 4; $i++)
{
$newIssues += New-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Title ([guid]::NewGuid().Guid)
Start-Sleep -Seconds 5
}

$newIssues[0] = Update-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $newIssues[0].number -State Closed
Expand Down