File tree Expand file tree Collapse file tree 5 files changed +22
-23
lines changed Expand file tree Collapse file tree 5 files changed +22
-23
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,11 @@ impl BranchInfo {
104104
105105 None
106106 }
107+
108+ /// returns whether branch is local
109+ pub const fn is_local ( & self ) -> bool {
110+ matches ! ( self . details, BranchDetails :: Local ( _) )
111+ }
107112}
108113
109114///
Original file line number Diff line number Diff line change @@ -909,8 +909,8 @@ impl App {
909909 InternalEvent :: CommitSearch ( options) => {
910910 self . revlog . search ( options) ;
911911 }
912- InternalEvent :: CheckoutOption ( branch, is_local ) => {
913- self . checkout_option_popup . open ( branch, is_local ) ?;
912+ InternalEvent :: CheckoutOption ( branch) => {
913+ self . checkout_option_popup . open ( branch) ?;
914914 }
915915 }
916916
Original file line number Diff line number Diff line change @@ -609,8 +609,7 @@ impl BranchListPopup {
609609 self . queue . push ( InternalEvent :: Update ( NeedsUpdate :: ALL ) ) ;
610610 } else {
611611 self . queue . push ( InternalEvent :: CheckoutOption (
612- selected_branch. clone ( ) ,
613- self . local ,
612+ selected_branch. clone ( )
614613 ) ) ;
615614 }
616615
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ use ratatui::{
2929pub struct CheckoutOptionPopup {
3030 queue : Queue ,
3131 repo : RepoPath ,
32- local : bool ,
3332 branch : Option < BranchInfo > ,
3433 option : CheckoutOptions ,
3534 visible : bool ,
@@ -43,7 +42,6 @@ impl CheckoutOptionPopup {
4342 Self {
4443 queue : env. queue . clone ( ) ,
4544 repo : env. repo . borrow ( ) . clone ( ) ,
46- local : false ,
4745 branch : None ,
4846 option : CheckoutOptions :: StashAndReapply ,
4947 visible : false ,
@@ -82,30 +80,27 @@ impl CheckoutOptionPopup {
8280 }
8381
8482 ///
85- pub fn open (
86- & mut self ,
87- branch : BranchInfo ,
88- is_local : bool ,
89- ) -> Result < ( ) > {
83+ pub fn open ( & mut self , branch : BranchInfo ) -> Result < ( ) > {
9084 self . show ( ) ?;
9185
9286 self . branch = Some ( branch) ;
93- self . local = is_local;
9487
9588 Ok ( ( ) )
9689 }
9790
9891 fn checkout ( & self ) -> Result < ( ) > {
99- if self . local {
100- checkout_branch (
101- & self . repo ,
102- & self . branch . as_ref ( ) . expect ( "No branch" ) . name ,
103- ) ?;
104- } else {
105- checkout_remote_branch (
106- & self . repo ,
107- self . branch . as_ref ( ) . expect ( "No branch" ) ,
108- ) ?;
92+ if let Some ( branch) = & self . branch {
93+ if branch. is_local ( ) {
94+ checkout_branch (
95+ & self . repo ,
96+ & self . branch . as_ref ( ) . expect ( "No branch" ) . name ,
97+ ) ?;
98+ } else {
99+ checkout_remote_branch (
100+ & self . repo ,
101+ self . branch . as_ref ( ) . expect ( "No branch" ) ,
102+ ) ?;
103+ }
109104 }
110105
111106 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ pub enum InternalEvent {
159159 ///
160160 CommitSearch ( LogFilterSearchOptions ) ,
161161 ///
162- CheckoutOption ( BranchInfo , bool ) ,
162+ CheckoutOption ( BranchInfo ) ,
163163}
164164
165165/// single threaded simple queue for components to communicate with each other
You can’t perform that action at this time.
0 commit comments