From 6cc0c54ac1925471db0b1766b970074c2c7c6e47 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 28 Oct 2024 17:55:32 +0800 Subject: [PATCH] enhance: remember last selection of some options while stashing changes (#610) Signed-off-by: leo --- src/Models/RepositorySettings.cs | 18 ++++++++++++++++++ src/ViewModels/StashChanges.cs | 16 ++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 40c00bc9..e8c66c04 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -112,6 +112,24 @@ namespace SourceGit.Models set; } = false; + public bool IncludeUntrackedWhenStash + { + get; + set; + } = true; + + public bool OnlyStagedWhenStash + { + get; + set; + } = false; + + public bool KeepIndexWhenStash + { + get; + set; + } = false; + public void PushCommitMessage(string message) { var existIdx = CommitMessages.IndexOf(message); diff --git a/src/ViewModels/StashChanges.cs b/src/ViewModels/StashChanges.cs index 82516880..1ad3a0da 100644 --- a/src/ViewModels/StashChanges.cs +++ b/src/ViewModels/StashChanges.cs @@ -18,31 +18,27 @@ namespace SourceGit.ViewModels public bool IncludeUntracked { - get; - set; + get => _repo.Settings.IncludeUntrackedWhenStash; + set => _repo.Settings.IncludeUntrackedWhenStash = value; } public bool OnlyStaged { - get; - set; + get => _repo.Settings.OnlyStagedWhenStash; + set => _repo.Settings.OnlyStagedWhenStash = value; } public bool KeepIndex { - get; - set; + get => _repo.Settings.KeepIndexWhenStash; + set => _repo.Settings.KeepIndexWhenStash = value; } public StashChanges(Repository repo, List changes, bool hasSelectedFiles) { _repo = repo; _changes = changes; - HasSelectedFiles = hasSelectedFiles; - IncludeUntracked = true; - OnlyStaged = false; - KeepIndex = false; View = new Views.StashChanges() { DataContext = this }; }