@@ -2,7 +2,7 @@ import { IChangedArgs, PathExt, URLExt } from '@jupyterlab/coreutils';
22import { IDocumentManager } from '@jupyterlab/docmanager' ;
33import { DocumentRegistry } from '@jupyterlab/docregistry' ;
44import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
5- import { JSONObject } from '@lumino/coreutils' ;
5+ import { JSONExt , JSONObject } from '@lumino/coreutils' ;
66import { Poll } from '@lumino/polling' ;
77import { ISignal , Signal } from '@lumino/signaling' ;
88import { requestAPI } from './git' ;
@@ -206,6 +206,13 @@ export class GitExtension implements IGitExtension {
206206 return this . _status ;
207207 }
208208
209+ /**
210+ * A signal emitted when the branches of the Git repository changes.
211+ */
212+ get branchesChanged ( ) : ISignal < IGitExtension , void > {
213+ return this . _branchesChanged ;
214+ }
215+
209216 /**
210217 * A signal emitted when the `HEAD` of the Git repository changes.
211218 */
@@ -912,7 +919,12 @@ export class GitExtension implements IGitExtension {
912919 this . _currentBranch . top_commit !== data . current_branch . top_commit ;
913920 }
914921
915- this . _branches = data . branches ;
922+ const branchesChanged = ! JSONExt . deepEqual (
923+ this . _branches as any ,
924+ ( data . branches ?? [ ] ) as any
925+ ) ;
926+
927+ this . _branches = data . branches ?? [ ] ;
916928 this . _currentBranch = data . current_branch ;
917929 if ( this . _currentBranch ) {
918930 // Set up the marker obj for the current (valid) repo/branch combination
@@ -921,6 +933,9 @@ export class GitExtension implements IGitExtension {
921933 if ( headChanged ) {
922934 this . _headChanged . emit ( ) ;
923935 }
936+ if ( branchesChanged ) {
937+ this . _branchesChanged . emit ( ) ;
938+ }
924939
925940 // Start fetch remotes if the repository has remote branches
926941 const hasRemote = this . _branches . some ( branch => branch . is_remote_branch ) ;
@@ -930,13 +945,17 @@ export class GitExtension implements IGitExtension {
930945 this . _fetchPoll . stop ( ) ;
931946 }
932947 } catch ( error ) {
948+ const branchesChanged = this . _branches . length > 0 ;
933949 const headChanged = this . _currentBranch !== null ;
934950 this . _branches = [ ] ;
935951 this . _currentBranch = null ;
936952 this . _fetchPoll . stop ( ) ;
937953 if ( headChanged ) {
938954 this . _headChanged . emit ( ) ;
939955 }
956+ if ( branchesChanged ) {
957+ this . _branchesChanged . emit ( ) ;
958+ }
940959
941960 if ( ! ( error instanceof Git . NotInRepository ) ) {
942961 throw error ;
@@ -1610,6 +1629,7 @@ export class GitExtension implements IGitExtension {
16101629 private _selectedHistoryFile : Git . IStatusFile | null = null ;
16111630 private _hasDirtyStagedFiles = false ;
16121631
1632+ private _branchesChanged = new Signal < IGitExtension , void > ( this ) ;
16131633 private _headChanged = new Signal < IGitExtension , void > ( this ) ;
16141634 private _markChanged = new Signal < IGitExtension , void > ( this ) ;
16151635 private _selectedHistoryFileChanged = new Signal <
0 commit comments