@@ -19,6 +19,19 @@ public Models.Commit Commit
1919 private set ;
2020 }
2121
22+ public bool CanSquashOrFixup
23+ {
24+ get => _canSquashOrFixup ;
25+ set
26+ {
27+ if ( SetProperty ( ref _canSquashOrFixup , value ) )
28+ {
29+ if ( _action == Models . InteractiveRebaseAction . Squash || _action == Models . InteractiveRebaseAction . Fixup )
30+ Action = Models . InteractiveRebaseAction . Pick ;
31+ }
32+ }
33+ }
34+
2235 public Models . InteractiveRebaseAction Action
2336 {
2437 get => _action ;
@@ -48,10 +61,11 @@ public string FullMessage
4861 }
4962 }
5063
51- public InteractiveRebaseItem ( Models . Commit c , string message )
64+ public InteractiveRebaseItem ( Models . Commit c , string message , bool canSquashOrFixup )
5265 {
5366 Commit = c ;
5467 FullMessage = message ;
68+ CanSquashOrFixup = canSquashOrFixup ;
5569 }
5670
5771 public void SetAction ( object param )
@@ -62,6 +76,7 @@ public void SetAction(object param)
6276 private Models . InteractiveRebaseAction _action = Models . InteractiveRebaseAction . Pick ;
6377 private string _subject ;
6478 private string _fullMessage ;
79+ private bool _canSquashOrFixup = true ;
6580 }
6681
6782 public class InteractiveRebase : ObservableObject
@@ -88,7 +103,7 @@ public AvaloniaList<InteractiveRebaseItem> Items
88103 {
89104 get ;
90105 private set ;
91- } = new AvaloniaList < InteractiveRebaseItem > ( ) ;
106+ } = [ ] ;
92107
93108 public InteractiveRebaseItem SelectedItem
94109 {
@@ -121,8 +136,11 @@ public InteractiveRebase(Repository repo, Models.Branch current, Models.Commit o
121136 var commits = new Commands . QueryCommitsForInteractiveRebase ( repoPath , on . SHA ) . Result ( ) ;
122137 var list = new List < InteractiveRebaseItem > ( ) ;
123138
124- foreach ( var c in commits )
125- list . Add ( new InteractiveRebaseItem ( c . Commit , c . Message ) ) ;
139+ for ( var i = 0 ; i < commits . Count ; i ++ )
140+ {
141+ var c = commits [ i ] ;
142+ list . Add ( new InteractiveRebaseItem ( c . Commit , c . Message , i < commits . Count - 1 ) ) ;
143+ }
126144
127145 Dispatcher . UIThread . Invoke ( ( ) =>
128146 {
@@ -140,6 +158,9 @@ public void MoveItemUp(InteractiveRebaseItem item)
140158 var prev = Items [ idx - 1 ] ;
141159 Items . RemoveAt ( idx - 1 ) ;
142160 Items . Insert ( idx , prev ) ;
161+
162+ item . CanSquashOrFixup = true ;
163+ prev . CanSquashOrFixup = idx < Items . Count - 1 ;
143164 SelectedItem = item ;
144165 }
145166 }
@@ -152,6 +173,9 @@ public void MoveItemDown(InteractiveRebaseItem item)
152173 var next = Items [ idx + 1 ] ;
153174 Items . RemoveAt ( idx + 1 ) ;
154175 Items . Insert ( idx , next ) ;
176+
177+ item . CanSquashOrFixup = idx < Items . Count - 2 ;
178+ next . CanSquashOrFixup = true ;
155179 SelectedItem = item ;
156180 }
157181 }
0 commit comments