feature: allow to ignore local changes also when switching branch or pulling changes (#151)

This commit is contained in:
leo 2024-05-29 16:42:47 +08:00
parent 69f9dceece
commit 0b09d210be
13 changed files with 253 additions and 212 deletions

View file

@ -2,14 +2,7 @@
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public enum BeforeCreateBranchAction
{
StashAndReaply,
Discard,
DoNothing,
}
{
public class CreateBranch : Popup
{
[Required(ErrorMessage = "Branch name is required!")]
@ -27,7 +20,7 @@ namespace SourceGit.ViewModels
private set;
}
public BeforeCreateBranchAction PreAction
public Models.DealWithLocalChanges PreAction
{
get => _preAction;
set => SetProperty(ref _preAction, value);
@ -97,7 +90,7 @@ namespace SourceGit.ViewModels
bool needPopStash = false;
if (_repo.WorkingCopyChangesCount > 0)
{
if (_preAction == BeforeCreateBranchAction.StashAndReaply)
if (_preAction == Models.DealWithLocalChanges.StashAndReaply)
{
SetProgressDescription("Adding untracked changes...");
var succ = new Commands.Add(_repo.FullPath).Exec();
@ -115,7 +108,7 @@ namespace SourceGit.ViewModels
needPopStash = true;
}
else if (_preAction == BeforeCreateBranchAction.Discard)
else if (_preAction == Models.DealWithLocalChanges.Discard)
{
SetProgressDescription("Discard local changes...");
Commands.Discard.All(_repo.FullPath);
@ -144,6 +137,6 @@ namespace SourceGit.ViewModels
private readonly Repository _repo = null;
private string _name = null;
private readonly string _baseOnRevision = null;
private BeforeCreateBranchAction _preAction = BeforeCreateBranchAction.StashAndReaply;
private Models.DealWithLocalChanges _preAction = Models.DealWithLocalChanges.StashAndReaply;
}
}