Skip to content

Commit

Permalink
Refactor Get-GitHubContext to improve default context retrieval and e…
Browse files Browse the repository at this point in the history
…rror handling
  • Loading branch information
MariusStorhaug committed Nov 24, 2024
1 parent 3d9671e commit 865ae0b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/functions/public/Auth/Context/Get-GitHubContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ function Get-GitHubContext {
Write-Verbose "Getting available contexts for [$ID]"
} else {
$config = Get-GitHubConfig
$Context = $config.DefaultContext
if ([string]::IsNullOrEmpty($Context)) {
$ID = $config.DefaultContext
if ([string]::IsNullOrEmpty($ID )) {
throw "No default GitHub context found. Please run 'Set-GitHubDefaultContext' or 'Connect-GitHub' to configure a GitHub context."
}
$ID = "$($script:Config.Name)/$Context"
Write-Verbose "Getting the default context: [$ID]"
}

Expand Down

0 comments on commit 865ae0b

Please sign in to comment.