mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-25 19:32:03 +08:00
fix: can not squash and fixup until first picked/edit/reword commit in interactive rebase exists list (#1362)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -35,7 +35,7 @@ namespace SourceGit.ViewModels
|
||||
public Models.InteractiveRebaseAction Action
|
||||
{
|
||||
get => _action;
|
||||
private set => SetProperty(ref _action, value);
|
||||
set => SetProperty(ref _action, value);
|
||||
}
|
||||
|
||||
public string Subject
|
||||
@@ -68,11 +68,6 @@ namespace SourceGit.ViewModels
|
||||
CanSquashOrFixup = canSquashOrFixup;
|
||||
}
|
||||
|
||||
public void SetAction(object param)
|
||||
{
|
||||
Action = (Models.InteractiveRebaseAction)param;
|
||||
}
|
||||
|
||||
private Models.InteractiveRebaseAction _action = Models.InteractiveRebaseAction.Pick;
|
||||
private string _subject;
|
||||
private string _fullMessage;
|
||||
@@ -158,10 +153,8 @@ namespace SourceGit.ViewModels
|
||||
var prev = Items[idx - 1];
|
||||
Items.RemoveAt(idx - 1);
|
||||
Items.Insert(idx, prev);
|
||||
|
||||
item.CanSquashOrFixup = true;
|
||||
prev.CanSquashOrFixup = idx < Items.Count - 1;
|
||||
SelectedItem = item;
|
||||
UpdateItems();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,13 +166,23 @@ namespace SourceGit.ViewModels
|
||||
var next = Items[idx + 1];
|
||||
Items.RemoveAt(idx + 1);
|
||||
Items.Insert(idx, next);
|
||||
|
||||
item.CanSquashOrFixup = idx < Items.Count - 2;
|
||||
next.CanSquashOrFixup = true;
|
||||
SelectedItem = item;
|
||||
UpdateItems();
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeAction(InteractiveRebaseItem item, Models.InteractiveRebaseAction action)
|
||||
{
|
||||
if (!item.CanSquashOrFixup)
|
||||
{
|
||||
if (action == Models.InteractiveRebaseAction.Squash || action == Models.InteractiveRebaseAction.Fixup)
|
||||
return;
|
||||
}
|
||||
|
||||
item.Action = action;
|
||||
UpdateItems();
|
||||
}
|
||||
|
||||
public Task<bool> Start()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
@@ -210,6 +213,27 @@ namespace SourceGit.ViewModels
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateItems()
|
||||
{
|
||||
if (Items.Count == 0)
|
||||
return;
|
||||
|
||||
var hasValidParent = false;
|
||||
for (var i = Items.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var item = Items[i];
|
||||
if (hasValidParent)
|
||||
{
|
||||
item.CanSquashOrFixup = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.CanSquashOrFixup = false;
|
||||
hasValidParent = item.Action != Models.InteractiveRebaseAction.Drop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Repository _repo = null;
|
||||
private bool _isLoading = false;
|
||||
private InteractiveRebaseItem _selectedItem = null;
|
||||
|
||||
Reference in New Issue
Block a user