@@ -15,12 +15,12 @@ import { IAccount, ILabel, IMilestone, IProject, isITeam, ITeam, MergeMethod, Re
1515import { BaseBranchMetadata , PullRequestGitHelper } from './pullRequestGitHelper' ;
1616import { PullRequestModel } from './pullRequestModel' ;
1717import { getDefaultMergeMethod } from './pullRequestOverview' ;
18- import { getAssigneesQuickPickItems , getLabelOptions , getMilestoneFromQuickPick , getProjectFromQuickPick , reviewersQuickPick } from './quickPicks' ;
18+ import { branchPicks , getAssigneesQuickPickItems , getLabelOptions , getMilestoneFromQuickPick , getProjectFromQuickPick , reviewersQuickPick } from './quickPicks' ;
1919import { getIssueNumberLabelFromParsed , ISSUE_EXPRESSION , ISSUE_OR_URL_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' ;
23- import type { Branch , Ref } from '../api/api' ;
23+ import type { Branch } from '../api/api' ;
2424import { GitHubServerType } from '../common/authentication' ;
2525import { emojify , ensureEmojis } from '../common/emoji' ;
2626import { commands , contexts } from '../common/executeCommands' ;
@@ -133,12 +133,6 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
133133 return repo . getRepoAccessAndMergeMethods ( refetch ) ;
134134 }
135135
136- protected getRecentlyUsedBranches ( owner : string , repositoryName : string ) : string [ ] {
137- const repoKey = `${ owner } /${ repositoryName } ` ;
138- const state = this . _folderRepositoryManager . context . workspaceState . get < RecentlyUsedBranchesState > ( RECENTLY_USED_BRANCHES , { branches : { } } ) ;
139- return state . branches [ repoKey ] || [ ] ;
140- }
141-
142136 protected saveRecentlyUsedBranch ( owner : string , repositoryName : string , branchName : string ) : void {
143137 const repoKey = `${ owner } /${ repositoryName } ` ;
144138 const state = this . _folderRepositoryManager . context . workspaceState . get < RecentlyUsedBranchesState > ( RECENTLY_USED_BRANCHES , { branches : { } } ) ;
@@ -901,77 +895,6 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
901895 } ) ;
902896 }
903897
904- private async branchPicks ( githubRepository : GitHubRepository , changeRepoMessage : string , isBase : boolean ) : Promise < ( vscode . QuickPickItem & { remote ?: RemoteInfo , branch ?: string } ) [ ] > {
905- let branches : ( string | Ref ) [ ] ;
906- if ( isBase ) {
907- // For the base, we only want to show branches from GitHub.
908- branches = await githubRepository . listBranches ( githubRepository . remote . owner , githubRepository . remote . repositoryName ) ;
909- } else {
910- // For the compare, we only want to show local branches.
911- branches = ( await this . _folderRepositoryManager . repository . getBranches ( { remote : false } ) ) . filter ( branch => branch . name ) ;
912- }
913-
914- const branchNames = branches . map ( branch => typeof branch === 'string' ? branch : branch . name ! ) ;
915-
916- // Get recently used branches for base branches only
917- let recentBranches : string [ ] = [ ] ;
918- let otherBranches : string [ ] = branchNames ;
919- if ( isBase ) {
920- const recentlyUsed = this . getRecentlyUsedBranches ( githubRepository . remote . owner , githubRepository . remote . repositoryName ) ;
921- // Include all recently used branches, even if they're not in the current branch list
922- // This allows showing branches that weren't fetched due to timeout
923- recentBranches = recentlyUsed ;
924- // Remove recently used branches from the main list (if they exist there)
925- otherBranches = branchNames . filter ( name => ! recentBranches . includes ( name ) ) ;
926- }
927-
928- const branchPicks : ( vscode . QuickPickItem & { remote ?: RemoteInfo , branch ?: string } ) [ ] = [ ] ;
929-
930- // Add recently used branches section
931- if ( recentBranches . length > 0 ) {
932- branchPicks . push ( {
933- kind : vscode . QuickPickItemKind . Separator ,
934- label : vscode . l10n . t ( 'Recently Used' )
935- } ) ;
936- recentBranches . forEach ( branchName => {
937- branchPicks . push ( {
938- iconPath : new vscode . ThemeIcon ( 'git-branch' ) ,
939- label : branchName ,
940- remote : {
941- owner : githubRepository . remote . owner ,
942- repositoryName : githubRepository . remote . repositoryName
943- } ,
944- branch : branchName
945- } ) ;
946- } ) ;
947- }
948-
949- // Add all other branches section
950- if ( otherBranches . length > 0 ) {
951- branchPicks . push ( {
952- kind : vscode . QuickPickItemKind . Separator ,
953- label : recentBranches . length > 0 ? vscode . l10n . t ( 'All Branches' ) : `${ githubRepository . remote . owner } /${ githubRepository . remote . repositoryName } `
954- } ) ;
955- otherBranches . forEach ( branchName => {
956- branchPicks . push ( {
957- iconPath : new vscode . ThemeIcon ( 'git-branch' ) ,
958- label : branchName ,
959- remote : {
960- owner : githubRepository . remote . owner ,
961- repositoryName : githubRepository . remote . repositoryName
962- } ,
963- branch : branchName
964- } ) ;
965- } ) ;
966- }
967-
968- branchPicks . unshift ( {
969- iconPath : new vscode . ThemeIcon ( 'repo' ) ,
970- label : changeRepoMessage
971- } ) ;
972- return branchPicks ;
973- }
974-
975898 private async processRemoteAndBranchResult ( githubRepository : GitHubRepository , result : { remote : RemoteInfo , branch : string } , isBase : boolean ) {
976899 const [ defaultBranch , viewerPermission ] = await Promise . all ( [ githubRepository . getDefaultBranch ( ) , githubRepository . getViewerPermission ( ) ] ) ;
977900
@@ -1052,7 +975,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
1052975 quickPick . placeholder = githubRepository ? branchPlaceholder : remotePlaceholder ;
1053976 quickPick . show ( ) ;
1054977 quickPick . busy = true ;
1055- quickPick . items = githubRepository ? await this . branchPicks ( githubRepository , chooseDifferentRemote , isBase ) : await this . remotePicks ( isBase ) ;
978+ quickPick . items = githubRepository ? await branchPicks ( githubRepository , this . _folderRepositoryManager , chooseDifferentRemote , isBase ) : await this . remotePicks ( isBase ) ;
1056979 const activeItem = message . args . currentBranch ? quickPick . items . find ( item => item . branch === message . args . currentBranch ) : undefined ;
1057980 quickPick . activeItems = activeItem ? [ activeItem ] : [ ] ;
1058981 quickPick . busy = false ;
@@ -1071,7 +994,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
1071994 const selectedRemote = selectedPick as vscode . QuickPickItem & { remote : RemoteInfo } ;
1072995 quickPick . busy = true ;
1073996 githubRepository = this . _folderRepositoryManager . findRepo ( repo => repo . remote . owner === selectedRemote . remote . owner && repo . remote . repositoryName === selectedRemote . remote . repositoryName ) ! ;
1074- quickPick . items = await this . branchPicks ( githubRepository , chooseDifferentRemote , isBase ) ;
997+ quickPick . items = await branchPicks ( githubRepository , this . _folderRepositoryManager , chooseDifferentRemote , isBase ) ;
1075998 quickPick . placeholder = branchPlaceholder ;
1076999 quickPick . busy = false ;
10771000 } else if ( selectedPick . branch && selectedPick . remote ) {
0 commit comments