@@ -5,7 +5,7 @@ use crate::{
55 CommandInfo , Component , DrawableComponent ,
66 } ,
77 keys:: SharedKeyConfig ,
8- queue:: { InternalEvent , Queue } ,
8+ queue:: { Action , InternalEvent , Queue } ,
99 strings, try_or_popup,
1010 ui:: { self , style:: SharedTheme } ,
1111} ;
@@ -131,7 +131,7 @@ impl PullComponent {
131131 self . git_fetch . last_result ( ) ?
132132 {
133133 if err. is_empty ( ) {
134- self . do_merge ( ) ?;
134+ self . try_ff_merge ( ) ?;
135135 } else {
136136 self . queue . borrow_mut ( ) . push_back (
137137 InternalEvent :: ShowErrorMsg ( format ! (
@@ -141,14 +141,13 @@ impl PullComponent {
141141 ) ;
142142 }
143143 }
144- self . hide ( ) ;
145144 }
146145
147146 Ok ( ( ) )
148147 }
149148
150149 // check if something is incoming and try a ff merge then
151- fn do_merge ( & self ) -> Result < ( ) > {
150+ fn try_ff_merge ( & mut self ) -> Result < ( ) > {
152151 let branch_compare =
153152 sync:: branch_compare_upstream ( CWD , & self . branch ) ?;
154153 if branch_compare. behind > 0 {
@@ -157,18 +156,30 @@ impl PullComponent {
157156 & self . branch ,
158157 ) ;
159158 if let Err ( err) = merge_res {
160- log:: error!( "ff merge failed: {}" , err) ;
161-
162- try_or_popup ! (
163- self ,
164- "merge failed:" ,
165- sync:: merge_upstream_commit( CWD , & self . branch)
166- ) ;
159+ log:: trace!( "ff merge failed: {}" , err) ;
160+ self . confirm_merge ( branch_compare. behind ) ;
161+ } else {
162+ self . hide ( ) ;
167163 }
168164 }
169165
170166 Ok ( ( ) )
171167 }
168+
169+ pub fn try_conflict_free_merge ( & self ) {
170+ try_or_popup ! (
171+ self ,
172+ "merge failed:" ,
173+ sync:: merge_upstream_commit( CWD , & self . branch)
174+ ) ;
175+ }
176+
177+ fn confirm_merge ( & mut self , incoming : usize ) {
178+ self . queue . borrow_mut ( ) . push_back (
179+ InternalEvent :: ConfirmAction ( Action :: PullMerge ( incoming) ) ,
180+ ) ;
181+ self . hide ( ) ;
182+ }
172183}
173184
174185impl DrawableComponent for PullComponent {
@@ -232,7 +243,7 @@ impl Component for PullComponent {
232243
233244 fn event ( & mut self , ev : Event ) -> Result < bool > {
234245 if self . visible {
235- if let Event :: Key ( e ) = ev {
246+ if let Event :: Key ( _ ) = ev {
236247 if self . input_cred . is_visible ( ) {
237248 if self . input_cred . event ( ev) ? {
238249 return Ok ( true ) ;
@@ -243,10 +254,6 @@ impl Component for PullComponent {
243254 ) ) ?;
244255 self . input_cred . hide ( ) ;
245256 }
246- } else if e == self . key_config . exit_popup
247- && !self . pending
248- {
249- self . hide ( ) ;
250257 }
251258 }
252259 return Ok ( true ) ;
0 commit comments