mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-23 10:22:13 +08:00
refactor: remove ViewModels.WorkingCopy.StashAllAsync method
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -1112,8 +1112,14 @@ namespace SourceGit.ViewModels
|
||||
|
||||
public async Task StashAllAsync(bool autoStart)
|
||||
{
|
||||
if (_workingCopy != null)
|
||||
await _workingCopy.StashAllAsync(autoStart);
|
||||
if (!CanCreatePopup())
|
||||
return;
|
||||
|
||||
var popup = new StashChanges(this, null);
|
||||
if (autoStart)
|
||||
await ShowAndStartPopupAsync(popup);
|
||||
else
|
||||
ShowPopup(popup);
|
||||
}
|
||||
|
||||
public async Task SkipMergeAsync()
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SourceGit.ViewModels
|
||||
|
||||
public bool HasSelectedFiles
|
||||
{
|
||||
get;
|
||||
get => _changes != null;
|
||||
}
|
||||
|
||||
public bool IncludeUntracked
|
||||
@@ -43,11 +43,10 @@ namespace SourceGit.ViewModels
|
||||
set => _repo.Settings.ChangesAfterStashing = value;
|
||||
}
|
||||
|
||||
public StashChanges(Repository repo, List<Models.Change> changes, bool hasSelectedFiles)
|
||||
public StashChanges(Repository repo, List<Models.Change> selectedChanges)
|
||||
{
|
||||
_repo = repo;
|
||||
_changes = changes;
|
||||
HasSelectedFiles = hasSelectedFiles;
|
||||
_changes = selectedChanges;
|
||||
}
|
||||
|
||||
public override async Task<bool> Sure()
|
||||
@@ -62,7 +61,7 @@ namespace SourceGit.ViewModels
|
||||
var keepIndex = mode == DealWithChangesAfterStashing.KeepIndex;
|
||||
bool succ;
|
||||
|
||||
if (!HasSelectedFiles)
|
||||
if (_changes == null)
|
||||
{
|
||||
if (OnlyStaged)
|
||||
{
|
||||
@@ -74,8 +73,12 @@ namespace SourceGit.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
var all = await new Commands.QueryLocalChanges(_repo.FullPath, false)
|
||||
.Use(log)
|
||||
.GetResultAsync();
|
||||
|
||||
var staged = new List<Models.Change>();
|
||||
foreach (var c in _changes)
|
||||
foreach (var c in all)
|
||||
{
|
||||
if (c.Index != Models.ChangeState.None && c.Index != Models.ChangeState.Untracked)
|
||||
staged.Add(c);
|
||||
|
||||
@@ -342,17 +342,6 @@ namespace SourceGit.ViewModels
|
||||
Native.OS.OpenWithDefaultEditor(absPath);
|
||||
}
|
||||
|
||||
public async Task StashAllAsync(bool autoStart)
|
||||
{
|
||||
if (!_repo.CanCreatePopup())
|
||||
return;
|
||||
|
||||
if (autoStart)
|
||||
await _repo.ShowAndStartPopupAsync(new StashChanges(_repo, _cached, false));
|
||||
else
|
||||
_repo.ShowPopup(new StashChanges(_repo, _cached, false));
|
||||
}
|
||||
|
||||
public async Task StageChangesAsync(List<Models.Change> changes, Models.Change next)
|
||||
{
|
||||
var canStaged = await GetCanStageChangesAsync(changes);
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace SourceGit.Views
|
||||
stash.Click += (_, e) =>
|
||||
{
|
||||
if (repo.CanCreatePopup())
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedUnstaged, true));
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedUnstaged));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
@@ -769,7 +769,7 @@ namespace SourceGit.Views
|
||||
stash.Click += (_, e) =>
|
||||
{
|
||||
if (repo.CanCreatePopup())
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedUnstaged, true));
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedUnstaged));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
@@ -956,7 +956,7 @@ namespace SourceGit.Views
|
||||
stash.Click += (_, e) =>
|
||||
{
|
||||
if (repo.CanCreatePopup())
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedStaged, true));
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedStaged));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
@@ -1164,7 +1164,7 @@ namespace SourceGit.Views
|
||||
stash.Click += (_, e) =>
|
||||
{
|
||||
if (repo.CanCreatePopup())
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedStaged, true));
|
||||
repo.ShowPopup(new ViewModels.StashChanges(repo, selectedStaged));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user