Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions src/ViewModels/InteractiveRebase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,36 @@ public string FullMessage
}
}

public InteractiveRebaseItem(Models.Commit c, string message)
public bool HasParent
{
get
{
if (_parent?.Items == null || _parent.On == null)
return true;

var isLastCommit = _parent.Items.IndexOf(this) == _parent.Items.Count - 1;
if (!isLastCommit)
return true;

return _parent.On.Parents?.Count > 0;
}
}

private readonly InteractiveRebase _parent;

public InteractiveRebaseItem(Models.Commit c, string message, InteractiveRebase parent)
{
Commit = c;
FullMessage = message;
_parent = parent;
}

public void SetAction(object param)
{
Action = (Models.InteractiveRebaseAction)param;
var action = (Models.InteractiveRebaseAction)param;
if ((action is Models.InteractiveRebaseAction.Squash or Models.InteractiveRebaseAction.Fixup) && !HasParent)
return;
Action = action;
}

private Models.InteractiveRebaseAction _action = Models.InteractiveRebaseAction.Pick;
Expand Down Expand Up @@ -122,7 +143,7 @@ public InteractiveRebase(Repository repo, Models.Branch current, Models.Commit o
var list = new List<InteractiveRebaseItem>();

foreach (var c in commits)
list.Add(new InteractiveRebaseItem(c.Commit, c.Message));
list.Add(new InteractiveRebaseItem(c.Commit, c.Message, this));

Dispatcher.UIThread.Invoke(() =>
{
Expand Down
6 changes: 4 additions & 2 deletions src/Views/InteractiveRebase.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
</MenuItem.Header>
</MenuItem>

<MenuItem InputGesture="S" Command="{Binding SetAction}" CommandParameter="{x:Static m:InteractiveRebaseAction.Squash}">
<MenuItem InputGesture="S" Command="{Binding SetAction}" CommandParameter="{x:Static m:InteractiveRebaseAction.Squash}"
IsVisible="{Binding HasParent}">
<MenuItem.Icon>
<Ellipse Width="14" Height="14" Fill="LightGray"/>
</MenuItem.Icon>
Expand All @@ -155,7 +156,8 @@
</MenuItem.Header>
</MenuItem>

<MenuItem InputGesture="F" Command="{Binding SetAction}" CommandParameter="{x:Static m:InteractiveRebaseAction.Fixup}">
<MenuItem InputGesture="F" Command="{Binding SetAction}" CommandParameter="{x:Static m:InteractiveRebaseAction.Fixup}"
IsVisible="{Binding HasParent}">
<MenuItem.Icon>
<Ellipse Width="14" Height="14" Fill="LightGray"/>
</MenuItem.Icon>
Expand Down