11import type { ConfigurationChangeEvent } from 'vscode' ;
22import { Disposable , workspace } from 'vscode' ;
33import type { CreatePullRequestActionContext } from '../../api/gitlens' ;
4+ import type { EnrichedAutolink } from '../../autolinks' ;
45import { getAvatarUriFromGravatarEmail } from '../../avatars' ;
56import type { OpenPullRequestOnRemoteCommandArgs } from '../../commands/openPullRequestOnRemote' ;
67import { GlyphChars , urls } from '../../constants' ;
@@ -915,6 +916,7 @@ async function getOverviewBranches(
915916
916917 let repoStatusPromise : Promise < GitStatus | undefined > | undefined ;
917918 const prPromises = new Map < string , Promise < PullRequest | undefined > > ( ) ;
919+ const autolinkPromises = new Map < string , Promise < Map < string , EnrichedAutolink > | undefined > > ( ) ;
918920 const statusPromises = new Map < string , Promise < GitStatus | undefined > > ( ) ;
919921 const contributorPromises = new Map < string , Promise < BranchContributorOverview | undefined > > ( ) ;
920922
@@ -929,6 +931,7 @@ async function getOverviewBranches(
929931 if ( branch . current || wt ?. opened ) {
930932 const forceOptions = options ?. forceActive ? { force : true } : undefined ;
931933 prPromises . set ( branch . id , branch . getAssociatedPullRequest ( { avatarSize : 16 } ) ) ;
934+ autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
932935 if ( wt != null ) {
933936 statusPromises . set ( branch . id , wt . getStatus ( forceOptions ) ) ;
934937 } else {
@@ -955,6 +958,7 @@ async function getOverviewBranches(
955958
956959 if ( timestamp != null && timestamp > recentThreshold ) {
957960 prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
961+ autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
958962 if ( wt != null ) {
959963 statusPromises . set ( branch . id , wt . getStatus ( ) ) ;
960964 }
@@ -982,6 +986,7 @@ async function getOverviewBranches(
982986 orderBy : 'date:asc' ,
983987 } ) ;
984988 for ( const branch of branches ) {
989+ autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
985990 if ( overviewBranches . stale . length > 9 ) break ;
986991
987992 if (
@@ -1025,7 +1030,7 @@ async function getOverviewBranches(
10251030 }
10261031 }
10271032
1028- await enrichOverviewBranches ( overviewBranches , prPromises , statusPromises , contributorPromises ) ;
1033+ await enrichOverviewBranches ( overviewBranches , prPromises , autolinkPromises , statusPromises , contributorPromises ) ;
10291034
10301035 return overviewBranches ;
10311036}
@@ -1034,11 +1039,17 @@ async function getOverviewBranches(
10341039async function enrichOverviewBranches (
10351040 overviewBranches : GetOverviewBranches ,
10361041 prPromises : Map < string , Promise < PullRequest | undefined > > ,
1042+ autolinkPromises : Map < string , Promise < Map < string , EnrichedAutolink > | undefined > > ,
10371043 statusPromises : Map < string , Promise < GitStatus | undefined > > ,
10381044 contributorPromises : Map < string , Promise < BranchContributorOverview | undefined > > ,
10391045) {
1040- const [ prResults , statusResults , contributorResults ] = await Promise . allSettled ( [
1046+ const [ prResults , autolinkResults , statusResults , contributorResults ] = await Promise . allSettled ( [
10411047 Promise . allSettled ( map ( prPromises , ( [ id , pr ] ) => pr . then < [ string , PullRequest | undefined ] > ( pr => [ id , pr ] ) ) ) ,
1048+ Promise . allSettled (
1049+ map ( autolinkPromises , ( [ id , autolinks ] ) =>
1050+ autolinks . then < [ string , Map < string , EnrichedAutolink > | undefined ] > ( a => [ id , a ] ) ,
1051+ ) ,
1052+ ) ,
10421053 Promise . allSettled (
10431054 map ( statusPromises , ( [ id , status ] ) => status . then < [ string , GitStatus | undefined ] > ( status => [ id , status ] ) ) ,
10441055 ) ,
@@ -1065,6 +1076,40 @@ async function enrichOverviewBranches(
10651076 ] ) ,
10661077 ) ;
10671078
1079+ const enrichedAutolinkPromises = new Map (
1080+ getSettledValue ( autolinkResults )
1081+ ?. filter ( r => r . status === 'fulfilled' )
1082+ . map ( ( { value : [ autolinkId , autolinks ] } ) => [
1083+ autolinkId ,
1084+ autolinks
1085+ ? [ ...autolinks . values ( ) ]
1086+ . filter ( autolink => autolink ?. [ 0 ] != null )
1087+ . map ( async autolink => {
1088+ const issue = await autolink [ 0 ] ! ;
1089+ return {
1090+ id : autolink [ 1 ] . id ,
1091+ title : issue ?. title ?? autolink [ 1 ] . title ?? `Issue #${ autolink [ 1 ] . id } ` ,
1092+ state : issue ?. state === 'closed' ? 'closed' : 'opened' ,
1093+ url : autolink [ 1 ] . url ,
1094+ hasIssue : issue != null ,
1095+ } ;
1096+ } )
1097+ : undefined ,
1098+ ] ) ,
1099+ ) ;
1100+
1101+ const autolinks = new Map < string , GetOverviewBranch [ 'autolinks' ] > ( ) ;
1102+
1103+ for ( const [ id , enrichedAutolinkPromise ] of enrichedAutolinkPromises . entries ( ) ) {
1104+ if ( enrichedAutolinkPromise == null ) continue ;
1105+ const enrichedAutolinks = await Promise . all ( enrichedAutolinkPromise ) ;
1106+ if ( ! enrichedAutolinks . length ) continue ;
1107+ autolinks . set (
1108+ id ,
1109+ enrichedAutolinks . filter ( a => a . hasIssue ) ,
1110+ ) ;
1111+ }
1112+
10681113 const statuses = new Map (
10691114 getSettledValue ( statusResults )
10701115 ?. filter ( r => r . status === 'fulfilled' )
@@ -1081,6 +1126,9 @@ async function enrichOverviewBranches(
10811126 const pr = prs . get ( branch . id ) ;
10821127 branch . pr = pr ;
10831128
1129+ const autolinksForBranch = autolinks . get ( branch . id ) ;
1130+ branch . autolinks = autolinksForBranch ;
1131+
10841132 const status = statuses . get ( branch . id ) ;
10851133 if ( status != null ) {
10861134 branch . workingTreeState = status . getDiffStatus ( ) ;
0 commit comments