Skip to content

Commit 1328263

Browse files
committed
fix: issues
1 parent a8b0427 commit 1328263

2 files changed

Lines changed: 8 additions & 41 deletions

File tree

src/Action/Issue.psm1

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,8 @@
11
Join-Path $PSScriptRoot '..\Helpers.psm1' | Import-Module
2+
Join-Path $PSScriptRoot '..\Github.psm1' | Import-Module
23
Join-Path $PSScriptRoot 'Issue' | Get-ChildItem -Filter '*.psm1' | Select-Object -ExpandProperty Fullname | Import-Module
34

4-
function Invoke-GithubGraphQLQuery {
5-
<#
6-
.SYNOPSIS
7-
Execute a GraphQL query to GitHub API.
8-
.PARAMETER Query
9-
GraphQL query string.
10-
.PARAMETER Variables
11-
Hashtable of variables for the query.
12-
#>
13-
param(
14-
[Parameter(Mandatory)]
15-
[String] $Query,
16-
[Hashtable] $Variables
17-
)
18-
19-
$graphqlUrl = 'https://api.github.com/graphql'
20-
$body = @{ 'query' = $Query }
21-
if ($Variables) { $body['variables'] = $Variables }
22-
23-
$parameters = @{
24-
'Headers' = @{
25-
'Authorization' = "Bearer $env:GITHUB_TOKEN"
26-
'Accept' = 'application/json'
27-
}
28-
'Method' = 'Post'
29-
'Uri' = $graphqlUrl
30-
'Body' = (ConvertTo-Json $body -Depth 10)
31-
'ContentType' = 'application/json'
32-
}
33-
34-
Write-Log 'GraphQL Request' $parameters.Uri
355

36-
$response = Invoke-WebRequest @parameters
37-
$env:GH_REQUEST_COUNTER = ([int] $env:GH_REQUEST_COUNTER) + 1
38-
39-
return $response
40-
}
416

427
function Test-Hash {
438
param (
@@ -128,7 +93,7 @@ function Test-Hash {
12893

12994
try {
13095
Write-Log 'Attempting GraphQL query for repository and PRs...'
131-
$response = Invoke-GithubGraphQLQuery -Query $graphqlQuery -Variables @{
96+
$response = Invoke-GithubGraphQL -Query $graphqlQuery -Variables @{
13297
owner = $owner
13398
repo = $repo
13499
}
@@ -145,7 +110,7 @@ function Test-Hash {
145110
Write-Log "GraphQL query failed, falling back to REST API: $($_.Exception.Message)"
146111
# Fallback to REST API
147112
$masterBranch = ((Invoke-GithubRequest "repos/$REPOSITORY").Content | ConvertFrom-Json).default_branch
148-
$prs = (Invoke-GithubRequest "repos/$REPOSITORY/pulls?state=open&base=$masterBranch&sorting=updated").Content | ConvertFrom-Json
113+
$prs = (Invoke-GithubRequest "repos/$REPOSITORY/pulls?state=open&base=$masterBranch&sort=updated").Content | ConvertFrom-Json
149114
}
150115

151116
$message = @('You are right. Thank you for reporting.')

src/Github.psm1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function Invoke-GithubGraphQL {
1919
[Parameter(Mandatory, ValueFromPipeline)]
2020
[String] $Query,
2121
[Hashtable] $Variables,
22-
[Switch] $UseFallback,
2322
[Int] $MaxRetries = 3
2423
)
2524

@@ -144,7 +143,7 @@ function Invoke-GithubGraphQLParallel {
144143

145144
try {
146145
$response = Invoke-WebRequest @parameters
147-
$env:GH_REQUEST_COUNTER = ([int] $env:GH_REQUEST_COUNTER) + 1
146+
return @{ Success = $true; Data = $response }
148147
return @{ Success = $true; Data = $response }
149148
} catch {
150149
return @{ Success = $false; Error = $_.Exception.Message }
@@ -172,6 +171,9 @@ function Invoke-GithubGraphQLParallel {
172171
}
173172
}
174173

174+
# Update parent process counter after all runspaces complete
175+
$env:GH_REQUEST_COUNTER = ([int]$env:GH_REQUEST_COUNTER) + $results.Count
176+
175177
$runspacePool.Close()
176178
$runspacePool.Dispose()
177179

@@ -497,5 +499,5 @@ function Get-LogURL {
497499
return $logURL
498500
}
499501

500-
Export-ModuleMember -Function Invoke-GithubRequest, Invoke-GithubGraphQL, Invoke-GithubGraphQLParallel, Add-Comment, Get-AllChangedFilesInPR, New-Issue, Close-Issue, `
502+
Export-ModuleMember -Function Invoke-GithubRequest, Invoke-GithubGraphQL, Invoke-GithubGraphQLParallel, Add-Comment, Get-AllChangedFilesInPR, New-Issue, Close-Issue, `
501503
Add-Label, Remove-Label, Get-RateLimit, Get-JobID, Get-LogURL

0 commit comments

Comments
 (0)