@@ -19,6 +19,19 @@ public Models.Commit Commit
19
19
private set ;
20
20
}
21
21
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
+
22
35
public Models . InteractiveRebaseAction Action
23
36
{
24
37
get => _action ;
@@ -48,10 +61,11 @@ public string FullMessage
48
61
}
49
62
}
50
63
51
- public InteractiveRebaseItem ( Models . Commit c , string message )
64
+ public InteractiveRebaseItem ( Models . Commit c , string message , bool canSquashOrFixup )
52
65
{
53
66
Commit = c ;
54
67
FullMessage = message ;
68
+ CanSquashOrFixup = canSquashOrFixup ;
55
69
}
56
70
57
71
public void SetAction ( object param )
@@ -62,6 +76,7 @@ public void SetAction(object param)
62
76
private Models . InteractiveRebaseAction _action = Models . InteractiveRebaseAction . Pick ;
63
77
private string _subject ;
64
78
private string _fullMessage ;
79
+ private bool _canSquashOrFixup = true ;
65
80
}
66
81
67
82
public class InteractiveRebase : ObservableObject
@@ -88,7 +103,7 @@ public AvaloniaList<InteractiveRebaseItem> Items
88
103
{
89
104
get ;
90
105
private set ;
91
- } = new AvaloniaList < InteractiveRebaseItem > ( ) ;
106
+ } = [ ] ;
92
107
93
108
public InteractiveRebaseItem SelectedItem
94
109
{
@@ -121,8 +136,11 @@ public InteractiveRebase(Repository repo, Models.Branch current, Models.Commit o
121
136
var commits = new Commands . QueryCommitsForInteractiveRebase ( repoPath , on . SHA ) . Result ( ) ;
122
137
var list = new List < InteractiveRebaseItem > ( ) ;
123
138
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
+ }
126
144
127
145
Dispatcher . UIThread . Invoke ( ( ) =>
128
146
{
@@ -140,6 +158,9 @@ public void MoveItemUp(InteractiveRebaseItem item)
140
158
var prev = Items [ idx - 1 ] ;
141
159
Items . RemoveAt ( idx - 1 ) ;
142
160
Items . Insert ( idx , prev ) ;
161
+
162
+ item . CanSquashOrFixup = true ;
163
+ prev . CanSquashOrFixup = idx < Items . Count - 1 ;
143
164
SelectedItem = item ;
144
165
}
145
166
}
@@ -152,6 +173,9 @@ public void MoveItemDown(InteractiveRebaseItem item)
152
173
var next = Items [ idx + 1 ] ;
153
174
Items . RemoveAt ( idx + 1 ) ;
154
175
Items . Insert ( idx , next ) ;
176
+
177
+ item . CanSquashOrFixup = idx < Items . Count - 2 ;
178
+ next . CanSquashOrFixup = true ;
155
179
SelectedItem = item ;
156
180
}
157
181
}
0 commit comments