@@ -42,7 +42,7 @@ import type {
4242 SupportedIssueIntegrationIds ,
4343 SupportedSelfHostedIntegrationIds ,
4444} from './integration' ;
45- import { isSelfHostedIntegrationId } from './providers/models' ;
45+ import { isHostingIntegrationId , isSelfHostedIntegrationId } from './providers/models' ;
4646import type { ProvidersApi } from './providers/providersApi' ;
4747
4848export interface ConnectionStateChangeEvent {
@@ -555,18 +555,59 @@ export class IntegrationService implements Disposable {
555555 } )
556556 async getMyIssues (
557557 integrationIds ?: ( SupportedHostingIntegrationIds | SupportedIssueIntegrationIds ) [ ] ,
558- cancellation ?: CancellationToken ,
558+ options ?: { openRepositoriesOnly ?: boolean ; cancellation ?: CancellationToken } ,
559559 ) : Promise < SearchedIssue [ ] | undefined > {
560560 const integrations : Map < Integration , ResourceDescriptor [ ] | undefined > = new Map ( ) ;
561- for ( const integrationId of integrationIds ?. length ? integrationIds : Object . values ( HostingIntegrationId ) ) {
561+ const hostingIntegrationIds = integrationIds ?. filter (
562+ id => id in HostingIntegrationId ,
563+ ) as SupportedHostingIntegrationIds [ ] ;
564+ const openRemotesByIntegrationId = new Map < IntegrationId , ResourceDescriptor [ ] > ( ) ;
565+ for ( const repository of this . container . git . openRepositories ) {
566+ const remotes = await repository . git . getRemotes ( ) ;
567+ if ( remotes . length === 0 ) continue ;
568+ for ( const remote of remotes ) {
569+ const remoteIntegration = await remote . getIntegration ( ) ;
570+ if ( remoteIntegration == null ) continue ;
571+ for ( const integrationId of hostingIntegrationIds ?. length
572+ ? hostingIntegrationIds
573+ : Object . values ( HostingIntegrationId ) ) {
574+ if (
575+ remoteIntegration . id === integrationId &&
576+ remote . provider ?. owner != null &&
577+ remote . provider ?. repoName != null
578+ ) {
579+ const descriptor = {
580+ key : `${ remote . provider . owner } /${ remote . provider . repoName } ` ,
581+ owner : remote . provider . owner ,
582+ name : remote . provider . repoName ,
583+ } ;
584+ if ( openRemotesByIntegrationId . has ( integrationId ) ) {
585+ openRemotesByIntegrationId . get ( integrationId ) ?. push ( descriptor ) ;
586+ } else {
587+ openRemotesByIntegrationId . set ( integrationId , [ descriptor ] ) ;
588+ }
589+ }
590+ }
591+ }
592+ }
593+ for ( const integrationId of integrationIds ?. length
594+ ? integrationIds
595+ : [ ...Object . values ( HostingIntegrationId ) , ...Object . values ( IssueIntegrationId ) ] ) {
562596 const integration = await this . get ( integrationId ) ;
563597 if ( integration == null ) continue ;
564598
565- integrations . set ( integration , undefined ) ;
599+ integrations . set (
600+ integration ,
601+ options ?. openRepositoriesOnly &&
602+ isHostingIntegrationId ( integrationId ) &&
603+ openRemotesByIntegrationId . has ( integrationId )
604+ ? openRemotesByIntegrationId . get ( integrationId )
605+ : undefined ,
606+ ) ;
566607 }
567608 if ( integrations . size === 0 ) return undefined ;
568609
569- return this . getMyIssuesCore ( integrations , cancellation ) ;
610+ return this . getMyIssuesCore ( integrations , options ?. cancellation ) ;
570611 }
571612
572613 private async getMyIssuesCore (
0 commit comments