Skip to content

Commit a69dbce

Browse files
Support user-context local catalog testing
Allow Show-RepoList to reuse non-App contexts locally, rely on supported repository properties, and suppress expected 404s for optional workflow files. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 07138a2 commit a69dbce

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

.github/actions/update-index/src/Helper.psm1

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,21 @@ function Show-RepoList {
3434
)
3535

3636
LogGroup "Connect to organization [$Owner]" {
37-
Connect-GitHubApp -Organization $Owner -Default
37+
$currentContext = Get-GitHubContext -ErrorAction SilentlyContinue
38+
if ($null -eq $currentContext) {
39+
Connect-GitHubApp -Organization $Owner -Default
40+
}
41+
elseif ($currentContext.AuthType -eq 'App') {
42+
Connect-GitHubApp -Organization $Owner -Default
43+
}
44+
else {
45+
Write-Output "Using existing GitHub context [$($currentContext.Name)] with auth type [$($currentContext.AuthType)]"
46+
}
3847
Get-GitHubContext | Select-Object * | Format-List | Out-String
3948
}
4049

4150
LogGroup "Get repositories for organization [$Owner]" {
42-
$rawRepos = Get-GitHubRepository -Owner $Owner -AdditionalProperty @(
43-
'description',
44-
'default_branch',
45-
'stargazers_count',
46-
'open_issues_count',
47-
'html_url'
48-
)
51+
$rawRepos = Get-GitHubRepository -Owner $Owner
4952
Write-Output "Found $($rawRepos.Count) repositories"
5053
$repos = $rawRepos | ForEach-Object {
5154
$rawRepo = $_
@@ -57,9 +60,9 @@ function Show-RepoList {
5760
Type = $type
5861
Description = $rawRepo.Description
5962
DefaultBranch = $rawRepo.DefaultBranch
60-
Stars = $rawRepo.StargazersCount
61-
OpenIssuesCount = $rawRepo.OpenIssuesCount
62-
HtmlUrl = $rawRepo.HtmlUrl
63+
Stars = $rawRepo.Stargazers
64+
OpenIssuesCount = $rawRepo.OpenIssues
65+
HtmlUrl = $rawRepo.Url
6366
}
6467
}
6568
} | Sort-Object Type, Name
@@ -220,8 +223,15 @@ function Invoke-GitHubApi {
220223
if ($_.Exception.Response) {
221224
$statusCode = $_.Exception.Response.StatusCode.value__
222225
}
226+
$exceptionMessage = [string]$_.Exception.Message
223227
$errorText = $_ | Out-String
224-
if ($statusCode -eq 404 -or $errorText -match 'StatusCode\s*:\s*404' -or $errorText -match '\(404\)') {
228+
if (
229+
$statusCode -eq 404 -or
230+
$exceptionMessage -match '\b404\b' -or
231+
$exceptionMessage -match 'Not Found' -or
232+
$errorText -match 'StatusCode\s*:\s*404' -or
233+
$errorText -match '\(404\)'
234+
) {
225235
return $null
226236
}
227237

0 commit comments

Comments
 (0)