@@ -33,7 +33,7 @@ import {
3333} from './folderRepositoryManager' ;
3434import { GitHubRepository } from './githubRepository' ;
3535import { IAccount , ILabel , IMilestone , IProject , isTeam , ITeam , MergeMethod , RepoAccessAndMergeMethods } from './interface' ;
36- import { BaseBranchMetadata } from './pullRequestGitHelper' ;
36+ import { BaseBranchMetadata , PullRequestGitHelper } from './pullRequestGitHelper' ;
3737import { PullRequestModel } from './pullRequestModel' ;
3838import { getDefaultMergeMethod } from './pullRequestOverview' ;
3939import { getAssigneesQuickPickItems , getLabelOptions , getMilestoneFromQuickPick , getProjectFromQuickPick , reviewersQuickPick } from './quickPicks' ;
@@ -605,7 +605,8 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
605605 baseRemote,
606606 baseBranch,
607607 compareRemote,
608- compareBranch
608+ compareBranch,
609+ warning : await this . existingPRMessage ( ) ,
609610 } ;
610611 // TODO: consider updating title and description
611612 return this . _postMessage ( {
@@ -616,19 +617,25 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
616617 } ) ) ;
617618 }
618619
620+ private async existingPRMessage ( ) : Promise < string | undefined > {
621+ const existingPR = await PullRequestGitHelper . getMatchingPullRequestMetadataForBranch ( this . _folderRepositoryManager . repository , this . model . compareBranch ) ;
622+ return existingPR ? vscode . l10n . t ( 'A pull request already exists for this branch.' ) : '' ;
623+ }
624+
619625 public async setDefaultCompareBranch ( compareBranch : Branch | undefined ) {
620626 const branchChanged = compareBranch && ( compareBranch . name !== this . model . compareBranch ) ;
621627 const currentCompareRemote = this . _folderRepositoryManager . gitHubRepositories . find ( repo => repo . remote . owner === this . model . compareOwner ) ?. remote . remoteName ;
622628 const branchRemoteChanged = compareBranch && ( compareBranch . upstream ?. remote !== currentCompareRemote ) ;
623629 if ( branchChanged || branchRemoteChanged ) {
624630 this . _defaultCompareBranch = compareBranch ! . name ! ;
625631 this . model . setCompareBranch ( compareBranch ! . name ) ;
626- this . changeBranch ( compareBranch ! . name ! , false ) . then ( titleAndDescription => {
632+ this . changeBranch ( compareBranch ! . name ! , false ) . then ( async titleAndDescription => {
627633 const params : Partial < CreateParamsNew > = {
628634 defaultTitle : titleAndDescription . title ,
629635 defaultDescription : titleAndDescription . description ,
630636 compareBranch : compareBranch ?. name ,
631- defaultCompareBranch : compareBranch ?. name
637+ defaultCompareBranch : compareBranch ?. name ,
638+ warning : await this . existingPRMessage ( ) ,
632639 } ;
633640 if ( ! branchRemoteChanged ) {
634641 return this . _postMessage ( {
0 commit comments