@@ -8,7 +8,7 @@ import type { GitCommit } from '../git/models/commit';
88import { isCommit } from '../git/models/commit' ;
99import type { GitBranchReference , GitRevisionReference } from '../git/models/reference' ;
1010import { getReferenceLabel } from '../git/models/reference' ;
11- import type { Repository , RepositoryChangeEvent } from '../git/models/repository' ;
11+ import type { RepositoryChangeEvent } from '../git/models/repository' ;
1212import { groupRepositories , RepositoryChange , RepositoryChangeComparisonMode } from '../git/models/repository' ;
1313import { getWorktreesByBranch } from '../git/models/worktree' ;
1414import { gate } from '../system/decorators/gate' ;
@@ -56,22 +56,22 @@ export class BranchesViewNode extends RepositoriesSubscribeableNode<BranchesView
5656 this . view . message = undefined ;
5757
5858 if ( this . children == null ) {
59- let grouped : Map < Repository , Map < string , Repository > > | undefined ;
60-
61- let repositories = this . view . container . git . openRepositories ;
62- if ( configuration . get ( 'views.collapseWorktreesWhenPossible' ) ) {
63- grouped = await groupRepositories ( repositories ) ;
64- repositories = [ ...grouped . keys ( ) ] ;
59+ if ( this . view . container . git . isDiscoveringRepositories ) {
60+ this . view . message = 'Loading branches...' ;
61+ await this . view . container . git . isDiscoveringRepositories ;
6562 }
6663
64+ let repositories = this . view . container . git . openRepositories ;
6765 if ( repositories . length === 0 ) {
68- this . view . message = this . view . container . git . isDiscoveringRepositories
69- ? 'Loading branches...'
70- : 'No branches could be found.' ;
71-
66+ this . view . message = 'No branches could be found.' ;
7267 return [ ] ;
7368 }
7469
70+ if ( configuration . get ( 'views.collapseWorktreesWhenPossible' ) ) {
71+ const grouped = await groupRepositories ( repositories ) ;
72+ repositories = [ ...grouped . keys ( ) ] ;
73+ }
74+
7575 // Get all the worktree branches (and track if they are opened) to pass along downstream, e.g. in the BranchNode to display an indicator
7676 const worktreesByBranch = await getWorktreesByBranch ( repositories , { includeDefault : true } ) ;
7777 this . updateContext ( {
0 commit comments