mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 20:54:59 +00:00
refactor: stash local changes (#550)
* when try to stash all the local changes, add a option to only stash the staged changes * stash changes in selected files will prompt user - both staged and unstaged changes of selected file(s) will be stashed
This commit is contained in:
parent
ac74e4ba32
commit
68519c76ca
6 changed files with 41 additions and 17 deletions
|
@ -11,7 +11,7 @@ namespace SourceGit.ViewModels
|
|||
set;
|
||||
}
|
||||
|
||||
public bool CanIgnoreUntracked
|
||||
public bool HasSelectedFiles
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
@ -22,21 +22,28 @@ namespace SourceGit.ViewModels
|
|||
set;
|
||||
}
|
||||
|
||||
public StashChanges(Repository repo, List<Models.Change> changes, bool onlyStaged, bool canIgnoreUntracked)
|
||||
public bool OnlyStaged
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public StashChanges(Repository repo, List<Models.Change> changes, bool hasSelectedFiles)
|
||||
{
|
||||
_repo = repo;
|
||||
_changes = changes;
|
||||
_onlyStaged = onlyStaged;
|
||||
|
||||
CanIgnoreUntracked = canIgnoreUntracked;
|
||||
HasSelectedFiles = hasSelectedFiles;
|
||||
IncludeUntracked = true;
|
||||
OnlyStaged = false;
|
||||
|
||||
View = new Views.StashChanges() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
var jobs = _changes;
|
||||
if (CanIgnoreUntracked && !IncludeUntracked)
|
||||
if (!HasSelectedFiles && !IncludeUntracked)
|
||||
{
|
||||
jobs = new List<Models.Change>();
|
||||
foreach (var job in _changes)
|
||||
|
@ -56,7 +63,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, _onlyStaged);
|
||||
var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, !HasSelectedFiles && OnlyStaged);
|
||||
CallUIThread(() =>
|
||||
{
|
||||
_repo.MarkWorkingCopyDirtyManually();
|
||||
|
@ -68,6 +75,5 @@ namespace SourceGit.ViewModels
|
|||
|
||||
private readonly Repository _repo = null;
|
||||
private readonly List<Models.Change> _changes = null;
|
||||
private readonly bool _onlyStaged = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue