@@ -285,6 +285,95 @@ public void CheckoutBranchByCommit(Models.Commit commit)
285285 }
286286 }
287287
288+ public async Task CherryPickAsync ( Models . Commit commit )
289+ {
290+ if ( _repo . CanCreatePopup ( ) )
291+ {
292+ if ( commit . Parents . Count <= 1 )
293+ {
294+ _repo . ShowPopup ( new CherryPick ( _repo , [ commit ] ) ) ;
295+ }
296+ else
297+ {
298+ var parents = new List < Models . Commit > ( ) ;
299+ foreach ( var sha in commit . Parents )
300+ {
301+ var parent = _commits . Find ( x => x . SHA == sha ) ;
302+ if ( parent == null )
303+ parent = await new Commands . QuerySingleCommit ( _repo . FullPath , sha ) . GetResultAsync ( ) ;
304+
305+ if ( parent != null )
306+ parents . Add ( parent ) ;
307+ }
308+
309+ _repo . ShowPopup ( new CherryPick ( _repo , commit , parents ) ) ;
310+ }
311+ }
312+ }
313+
314+ public async Task RewordHeadAsync ( Models . Commit head )
315+ {
316+ if ( _repo . CanCreatePopup ( ) )
317+ {
318+ var message = await new Commands . QueryCommitFullMessage ( _repo . FullPath , head . SHA ) . GetResultAsync ( ) ;
319+ _repo . ShowPopup ( new Reword ( _repo , head , message ) ) ;
320+ }
321+ }
322+
323+ public async Task SquashHeadAsync ( Models . Commit head )
324+ {
325+ if ( head . Parents . Count == 1 )
326+ {
327+ var message = await new Commands . QueryCommitFullMessage ( _repo . FullPath , head . SHA ) . GetResultAsync ( ) ;
328+ var parent = _commits . Find ( x => x . SHA . Equals ( head . Parents [ 0 ] ) ) ;
329+ if ( parent != null && _repo . CanCreatePopup ( ) )
330+ _repo . ShowPopup ( new Squash ( _repo , parent , message ) ) ;
331+ }
332+ }
333+
334+ public async Task InteractiveRebaseAsync ( Models . Commit commit , Models . InteractiveRebaseAction act )
335+ {
336+ var prefill = new InteractiveRebasePrefill ( commit . SHA , act ) ;
337+ var start = act switch
338+ {
339+ Models . InteractiveRebaseAction . Squash or Models . InteractiveRebaseAction . Fixup => $ "{ commit . SHA } ~~",
340+ _ => $ "{ commit . SHA } ~",
341+ } ;
342+
343+ var on = await new Commands . QuerySingleCommit ( _repo . FullPath , start ) . GetResultAsync ( ) ;
344+ if ( on == null )
345+ App . RaiseException ( _repo . FullPath , $ "Can not squash current commit into parent!") ;
346+ else
347+ await App . ShowDialog ( new InteractiveRebase ( _repo , on , prefill ) ) ;
348+ }
349+
350+ public async Task CopyCommitFullMessageAsync ( Models . Commit commit )
351+ {
352+ var message = await new Commands . QueryCommitFullMessage ( _repo . FullPath , commit . SHA ) . GetResultAsync ( ) ;
353+ await App . CopyTextAsync ( message ) ;
354+ }
355+
356+ public async Task < Models . Commit > CompareWithHeadAsync ( Models . Commit commit )
357+ {
358+ var head = _commits . Find ( x => x . IsCurrentHead ) ;
359+ if ( head == null )
360+ {
361+ _repo . SelectedSearchedCommit = null ;
362+ head = await new Commands . QuerySingleCommit ( _repo . FullPath , "HEAD" ) . GetResultAsync ( ) ;
363+ if ( head != null )
364+ DetailContext = new RevisionCompare ( _repo . FullPath , commit , head ) ;
365+
366+ return null ;
367+ }
368+
369+ return head ;
370+ }
371+
372+ public void CompareWithWorktree ( Models . Commit commit )
373+ {
374+ DetailContext = new RevisionCompare ( _repo . FullPath , commit , null ) ;
375+ }
376+
288377 private void NavigateTo ( Models . Commit commit )
289378 {
290379 AutoSelectedCommit = commit ;
0 commit comments