@@ -214,6 +214,8 @@ export class FolderRepositoryManager implements vscode.Disposable {
214
214
private _onDidDispose = new vscode . EventEmitter < void > ( ) ;
215
215
readonly onDidDispose : vscode . Event < void > = this . _onDidDispose . event ;
216
216
217
+ private _sessionIgnoredRemoteNames : Set < string > = new Set ( ) ;
218
+
217
219
constructor (
218
220
private _id : number ,
219
221
public context : vscode . ExtensionContext ,
@@ -330,7 +332,7 @@ export class FolderRepositoryManager implements vscode.Disposable {
330
332
331
333
return remotesSetting
332
334
. map ( remote => allGitHubRemotes . find ( repo => repo . remoteName === remote ) )
333
- . filter ( ( repo : GitHubRemote | undefined ) : repo is GitHubRemote => ! ! repo ) ;
335
+ . filter ( ( repo : GitHubRemote | undefined ) : repo is GitHubRemote => ! ! repo && ! this . _sessionIgnoredRemoteNames . has ( repo . remoteName ) ) ;
334
336
}
335
337
336
338
get activeIssue ( ) : IssueModel | undefined {
@@ -485,6 +487,17 @@ export class FolderRepositoryManager implements vscode.Disposable {
485
487
repositories . push ( repository ) ;
486
488
}
487
489
490
+ const cleanUpMissingSaml = async ( missingSaml : GitHubRepository [ ] ) => {
491
+ for ( const missing of missingSaml ) {
492
+ this . _sessionIgnoredRemoteNames . add ( missing . remote . remoteName ) ;
493
+ this . removeGitHubRepository ( missing . remote ) ;
494
+ const index = repositories . indexOf ( missing ) ;
495
+ if ( index > - 1 ) {
496
+ repositories . splice ( index , 1 ) ;
497
+ }
498
+ }
499
+ } ;
500
+
488
501
return Promise . all ( resolveRemotePromises ) . then ( async ( remoteResults : boolean [ ] ) => {
489
502
const missingSaml : GitHubRepository [ ] = [ ] ;
490
503
for ( let i = 0 ; i < remoteResults . length ; i ++ ) {
@@ -494,18 +507,18 @@ export class FolderRepositoryManager implements vscode.Disposable {
494
507
}
495
508
if ( missingSaml . length > 0 ) {
496
509
const result = await this . _credentialStore . showSamlMessageAndAuth ( missingSaml . map ( repo => repo . remote . owner ) ) ;
497
- if ( result . canceled ) {
498
- this . dispose ( ) ;
499
- return true ;
500
- } else {
501
- // Make a test call to see if the user has SAML enabled.
502
- const samlTest = await Promise . all ( missingSaml . map ( repo => repo . resolveRemote ( ) ) ) ;
503
-
504
- if ( samlTest . some ( result => ! result ) ) {
510
+ // Make a test call to see if the user has SAML enabled.
511
+ const samlTest = result . canceled ? [ ] : await Promise . all ( missingSaml . map ( repo => repo . resolveRemote ( ) ) ) ;
512
+ const stillMissing = result . canceled ? missingSaml : samlTest . map ( ( result , index ) => ! result ? missingSaml [ index ] : undefined ) . filter ( ( repo ) : repo is GitHubRepository => ! ! repo ) ;
513
+ // Make a test call to see if the user has SAML enabled.
514
+ if ( stillMissing . length > 0 ) {
515
+ if ( stillMissing . length === repositories . length ) {
505
516
await vscode . window . showErrorMessage ( vscode . l10n . t ( 'SAML access was not provided. GitHub Pull Requests will not work.' ) , { modal : true } ) ;
506
517
this . dispose ( ) ;
507
518
return true ;
508
519
}
520
+ await vscode . window . showErrorMessage ( vscode . l10n . t ( 'SAML access was not provided. Some GitHub repositories will not be available.' ) , { modal : true } ) ;
521
+ cleanUpMissingSaml ( stillMissing ) ;
509
522
}
510
523
}
511
524
@@ -2470,6 +2483,18 @@ export class FolderRepositoryManager implements vscode.Disposable {
2470
2483
return repo ;
2471
2484
}
2472
2485
2486
+ private removeGitHubRepository ( remote : Remote ) {
2487
+ const index = this . _githubRepositories . findIndex (
2488
+ r =>
2489
+ ( r . remote . owner . toLowerCase ( ) === remote . owner . toLowerCase ( ) )
2490
+ && ( r . remote . repositoryName . toLowerCase ( ) === remote . repositoryName . toLowerCase ( ) )
2491
+ && ( ! remote . remoteName || ( r . remote . remoteName === remote . remoteName ) )
2492
+ ) ;
2493
+ if ( index > - 1 ) {
2494
+ this . _githubRepositories . splice ( index , 1 ) ;
2495
+ }
2496
+ }
2497
+
2473
2498
private _createGitHubRepositoryBulkhead = bulkhead ( 1 , 300 ) ;
2474
2499
async createGitHubRepository ( remote : Remote , credentialStore : CredentialStore , silent ?: boolean , ignoreRemoteName : boolean = false ) : Promise < GitHubRepository > {
2475
2500
// Use a bulkhead/semaphore to ensure that we don't create multiple GitHubRepositories for the same remote at the same time.
0 commit comments