@@ -16,7 +16,7 @@ import { BaseBranchMetadata, PullRequestGitHelper } from './pullRequestGitHelper
1616import { PullRequestModel } from './pullRequestModel' ;
1717import { getDefaultMergeMethod } from './pullRequestOverview' ;
1818import { branchPicks , getAssigneesQuickPickItems , getLabelOptions , getMilestoneFromQuickPick , getProjectFromQuickPick , reviewersQuickPick } from './quickPicks' ;
19- import { getIssueNumberLabelFromParsed , ISSUE_EXPRESSION , ISSUE_OR_URL_EXPRESSION , parseIssueExpressionOutput , variableSubstitution } from './utils' ;
19+ import { ISSUE_EXPRESSION , parseIssueExpressionOutput , variableSubstitution } from './utils' ;
2020import { ChangeTemplateReply , DisplayLabel , PreReviewState } from './views' ;
2121import { RemoteInfo } from '../../common/types' ;
2222import { ChooseBaseRemoteAndBranchResult , ChooseCompareRemoteAndBranchResult , ChooseRemoteAndBranchArgs , CreateParamsNew , CreatePullRequestNew , TitleAndDescriptionArgs } from '../../common/views' ;
@@ -1142,57 +1142,8 @@ Don't forget to commit your template file to the repository so that it can be us
11421142 return this . _replyMessage ( message , chooseResult ) ;
11431143 }
11441144
1145- private async findIssueContext ( commits : string [ ] ) : Promise < { content : string , reference : string } [ ] | undefined > {
1146- const issues : Promise < { content : string , reference : string } | undefined > [ ] = [ ] ;
1147- for ( const commit of commits ) {
1148- const tryParse = parseIssueExpressionOutput ( commit . match ( ISSUE_OR_URL_EXPRESSION ) ) ;
1149- if ( tryParse ) {
1150- const owner = tryParse . owner ?? this . model . baseOwner ;
1151- const name = tryParse . name ?? this . model . repositoryName ;
1152- issues . push ( new Promise ( resolve => {
1153- this . _folderRepositoryManager . resolveIssue ( owner , name , tryParse . issueNumber ) . then ( issue => {
1154- if ( issue ) {
1155- resolve ( { content : `${ issue . title } \n${ issue . body } ` , reference : getIssueNumberLabelFromParsed ( tryParse ) } ) ;
1156- } else {
1157- resolve ( undefined ) ;
1158- }
1159- } ) . catch ( ( ) => resolve ( undefined ) ) ;
1160- } ) ) ;
1161- }
1162- }
1163- if ( issues . length ) {
1164- return ( await Promise . all ( issues ) ) . filter ( issue => ! ! issue ) as { content : string , reference : string } [ ] ;
1165- }
1166- return undefined ;
1167- }
1168-
11691145 private async getCommitsAndPatches ( ) : Promise < { commitMessages : string [ ] , patches : { patch : string , fileUri : string , previousFileUri ?: string } [ ] } > {
1170- let commitMessages : string [ ] ;
1171- let patches : ( { patch : string , fileUri : string , previousFileUri ?: string } | undefined ) [ ] | undefined ;
1172- if ( await this . model . getCompareHasUpstream ( ) ) {
1173- [ commitMessages , patches ] = await Promise . all ( [
1174- this . model . gitHubCommits ( ) . then ( rawCommits => rawCommits . map ( commit => commit . commit . message ) ) ,
1175- this . model . gitHubFiles ( ) . then ( rawPatches => rawPatches ?. map ( file => {
1176- if ( ! file . patch ) {
1177- return ;
1178- }
1179- const fileUri = vscode . Uri . joinPath ( this . _folderRepositoryManager . repository . rootUri , file . filename ) . toString ( ) ;
1180- const previousFileUri = file . previous_filename ? vscode . Uri . joinPath ( this . _folderRepositoryManager . repository . rootUri , file . previous_filename ) . toString ( ) : undefined ;
1181- return { patch : file . patch , fileUri, previousFileUri } ;
1182- } ) ) ] ) ;
1183- } else {
1184- [ commitMessages , patches ] = await Promise . all ( [
1185- this . model . gitCommits ( ) . then ( rawCommits => rawCommits . filter ( commit => commit . parents . length === 1 ) . map ( commit => commit . message ) ) ,
1186- Promise . all ( ( await this . model . gitFiles ( ) ) . map ( async ( file ) => {
1187- return {
1188- patch : await this . _folderRepositoryManager . repository . diffBetween ( this . model . baseBranch , this . model . compareBranch , file . uri . fsPath ) ,
1189- fileUri : file . uri . toString ( ) ,
1190- } ;
1191- } ) ) ] ) ;
1192- }
1193- const filteredPatches : { patch : string , fileUri : string , previousFileUri ?: string } [ ] =
1194- patches ?. filter < { patch : string , fileUri : string , previousFileUri ?: string } > ( ( patch ) : patch is { patch : string , fileUri : string , previousFileUri ?: string } => ! ! patch ) ?? [ ] ;
1195- return { commitMessages, patches : filteredPatches } ;
1146+ return this . model . getCommitsAndPatches ( ) ;
11961147 }
11971148
11981149 private lastGeneratedTitleAndDescription : { title ?: string , description ?: string , providerTitle : string } | undefined ;
@@ -1201,7 +1152,7 @@ Don't forget to commit your template file to the repository so that it can be us
12011152 try {
12021153 const templatePromise = this . getPullRequestTemplate ( ) ; // Fetch in parallel
12031154 const { commitMessages, patches } = await this . getCommitsAndPatches ( ) ;
1204- const issues = await this . findIssueContext ( commitMessages ) ;
1155+ const issues = await this . model . findIssueContext ( commitMessages ) ;
12051156 const template = await templatePromise ;
12061157
12071158 const provider = this . _folderRepositoryManager . getTitleAndDescriptionProvider ( searchTerm ) ;
0 commit comments