mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
refactor: rewrite amend behaviour (#300)
* toggle amend will show changes in HEAD commit * since discard is not compatible with staged changes in `amend` mode, we only allows user to discard unstaged changes
This commit is contained in:
parent
3c5a661fa0
commit
f55a576013
9 changed files with 261 additions and 86 deletions
|
@ -19,11 +19,10 @@ namespace SourceGit.ViewModels
|
|||
View = new Views.Discard { DataContext = this };
|
||||
}
|
||||
|
||||
public Discard(Repository repo, List<Models.Change> changes, bool isUnstaged)
|
||||
public Discard(Repository repo, List<Models.Change> changes)
|
||||
{
|
||||
_repo = repo;
|
||||
_changes = changes;
|
||||
_isUnstaged = isUnstaged;
|
||||
|
||||
if (_changes == null)
|
||||
Mode = new Models.Null();
|
||||
|
@ -44,10 +43,8 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
if (_changes == null)
|
||||
Commands.Discard.All(_repo.FullPath);
|
||||
else if (_isUnstaged)
|
||||
Commands.Discard.ChangesInWorkTree(_repo.FullPath, _changes);
|
||||
else
|
||||
Commands.Discard.ChangesInStaged(_repo.FullPath, _changes);
|
||||
Commands.Discard.Changes(_repo.FullPath, _changes);
|
||||
|
||||
CallUIThread(() =>
|
||||
{
|
||||
|
@ -61,6 +58,5 @@ namespace SourceGit.ViewModels
|
|||
|
||||
private readonly Repository _repo = null;
|
||||
private readonly List<Models.Change> _changes = null;
|
||||
private readonly bool _isUnstaged = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue