@@ -15,8 +15,7 @@ use anyhow::Result;
15
15
use asyncgit:: {
16
16
cached,
17
17
sync:: {
18
- self , get_branches_info, status:: StatusType , RepoPath ,
19
- RepoPathRef , RepoState ,
18
+ self , status:: StatusType , RepoPath , RepoPathRef , RepoState ,
20
19
} ,
21
20
sync:: { BranchCompare , CommitId } ,
22
21
AsyncDiff , AsyncGitNotification , AsyncStatus , DiffParams ,
@@ -67,6 +66,7 @@ pub struct Status {
67
66
index_wd : ChangesComponent ,
68
67
diff : DiffComponent ,
69
68
git_diff : AsyncDiff ,
69
+ has_remotes : bool ,
70
70
git_status_workdir : AsyncStatus ,
71
71
git_status_stage : AsyncStatus ,
72
72
git_branch_state : Option < BranchCompare > ,
@@ -161,6 +161,7 @@ impl Status {
161
161
Self {
162
162
queue : queue. clone ( ) ,
163
163
visible : true ,
164
+ has_remotes : false ,
164
165
focus : Focus :: WorkDir ,
165
166
diff_target : DiffTarget :: WorkingDir ,
166
167
index_wd : ChangesComponent :: new (
@@ -422,6 +423,13 @@ impl Status {
422
423
|| self . git_status_workdir . is_pending ( )
423
424
}
424
425
426
+ fn check_remotes ( & mut self ) {
427
+ self . has_remotes =
428
+ sync:: get_branches_info ( & self . repo . borrow ( ) , false )
429
+ . map ( |branches| !branches. is_empty ( ) )
430
+ . unwrap_or ( false ) ;
431
+ }
432
+
425
433
///
426
434
pub fn update_git (
427
435
& mut self ,
@@ -568,12 +576,6 @@ impl Status {
568
576
}
569
577
}
570
578
571
- fn has_remotes ( & self ) -> bool {
572
- get_branches_info ( & self . repo . borrow ( ) , false )
573
- . map ( |l| !l. is_empty ( ) )
574
- . unwrap_or ( false )
575
- }
576
-
577
579
fn pull ( & self ) {
578
580
if let Some ( branch) = self . git_branch_name . last ( ) {
579
581
self . queue . push ( InternalEvent :: Pull ( branch) ) ;
@@ -603,11 +605,11 @@ impl Status {
603
605
self . git_branch_state
604
606
. as_ref ( )
605
607
. map_or ( true , |state| state. ahead > 0 )
606
- && self . has_remotes ( )
608
+ && self . has_remotes
607
609
}
608
610
609
- fn can_pull ( & self ) -> bool {
610
- self . has_remotes ( ) && self . git_branch_state . is_some ( )
611
+ const fn can_pull ( & self ) -> bool {
612
+ self . has_remotes && self . git_branch_state . is_some ( )
611
613
}
612
614
613
615
fn can_abort_merge ( & self ) -> bool {
@@ -937,6 +939,7 @@ impl Component for Status {
937
939
938
940
fn show ( & mut self ) -> Result < ( ) > {
939
941
self . visible = true ;
942
+ self . check_remotes ( ) ;
940
943
self . update ( ) ?;
941
944
942
945
Ok ( ( ) )
0 commit comments