11import * as vscode from "vscode" ;
2-
3- import { logDebug , logError } from "../log" ;
4- import { API , GitExtension , RefType , RepositoryState } from "../typings/git" ;
5-
62import { Octokit } from "@octokit/rest" ;
7- import { getClient } from "../api/api" ;
8- import { getSession } from "../auth/auth " ;
3+
4+ import { handleSamlError } from "../api/handleSamlError " ;
95import { getRemoteName } from "../configuration/configuration" ;
106import { Protocol } from "../external/protocol" ;
7+ import { logDebug , logError } from "../log" ;
8+ import { API , GitExtension , RefType , RepositoryState } from "../typings/git" ;
119
1210interface GitHubUrls {
1311 workspaceUri : vscode . Uri ;
@@ -146,8 +144,6 @@ export async function getGitHubContext(): Promise<GitHubContext | undefined> {
146144
147145 try {
148146 const git = await getGitExtension ( ) ;
149- const session = await getSession ( ) ;
150- const client = getClient ( session . accessToken ) ;
151147
152148 const protocolInfos = await getGitHubUrls ( ) ;
153149 if ( ! protocolInfos ) {
@@ -157,29 +153,31 @@ export async function getGitHubContext(): Promise<GitHubContext | undefined> {
157153
158154 logDebug ( "Found protocol infos" , protocolInfos . length . toString ( ) ) ;
159155
160- const repos = await Promise . all (
161- protocolInfos . map ( async ( protocolInfo ) : Promise < GitHubRepoContext > => {
162- logDebug ( "Getting infos for repository" , protocolInfo . url ) ;
163-
164- const repoInfo = await client . repos . get ( {
165- repo : protocolInfo . protocol . repositoryName ,
166- owner : protocolInfo . protocol . owner
167- } ) ;
168-
169- const repo = git && git . getRepository ( protocolInfo . workspaceUri ) ;
170-
171- return {
172- workspaceUri : protocolInfo . workspaceUri ,
173- client,
174- repositoryState : repo ?. state ,
175- name : protocolInfo . protocol . repositoryName ,
176- owner : protocolInfo . protocol . owner ,
177- id : repoInfo . data . id ,
178- defaultBranch : `refs/heads/${ repoInfo . data . default_branch } ` ,
179- organizationOwned : repoInfo . data . owner . type === "Organization"
180- } ;
181- } )
182- ) ;
156+ const repos = await handleSamlError ( async ( client : Octokit ) => {
157+ return await Promise . all (
158+ protocolInfos . map ( async ( protocolInfo ) : Promise < GitHubRepoContext > => {
159+ logDebug ( "Getting infos for repository" , protocolInfo . url ) ;
160+
161+ const repoInfo = await client . repos . get ( {
162+ repo : protocolInfo . protocol . repositoryName ,
163+ owner : protocolInfo . protocol . owner
164+ } ) ;
165+
166+ const repo = git && git . getRepository ( protocolInfo . workspaceUri ) ;
167+
168+ return {
169+ workspaceUri : protocolInfo . workspaceUri ,
170+ client,
171+ repositoryState : repo ?. state ,
172+ name : protocolInfo . protocol . repositoryName ,
173+ owner : protocolInfo . protocol . owner ,
174+ id : repoInfo . data . id ,
175+ defaultBranch : `refs/heads/${ repoInfo . data . default_branch } ` ,
176+ organizationOwned : repoInfo . data . owner . type === "Organization"
177+ } ;
178+ } )
179+ ) ;
180+ } ) ;
183181
184182 gitHubContext = Promise . resolve ( {
185183 repos,
0 commit comments