diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index 7f7d1c00..644d52eb 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -12,8 +12,8 @@ namespace SourceGit.ViewModels public Models.DealWithLocalChanges PreAction { - get => _preAction; - set => SetProperty(ref _preAction, value); + get => _repo.Settings.DealWithLocalChangesOnCheckoutBranch; + set => _repo.Settings.DealWithLocalChangesOnCheckoutBranch = value; } public Checkout(Repository repo, string branch) @@ -34,7 +34,7 @@ namespace SourceGit.ViewModels var needPopStash = false; if (hasLocalChanges) { - if (_preAction == Models.DealWithLocalChanges.StashAndReaply) + if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { SetProgressDescription("Adding untracked changes ..."); var succ = new Commands.Add(_repo.FullPath).Exec(); @@ -52,7 +52,7 @@ namespace SourceGit.ViewModels needPopStash = true; } - else if (_preAction == Models.DealWithLocalChanges.Discard) + else if (PreAction == Models.DealWithLocalChanges.Discard) { SetProgressDescription("Discard local changes ..."); Commands.Discard.All(_repo.FullPath); @@ -78,6 +78,5 @@ namespace SourceGit.ViewModels } private readonly Repository _repo = null; - private Models.DealWithLocalChanges _preAction = Models.DealWithLocalChanges.DoNothing; } } diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index 2f7ac4f8..5e97cc86 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -22,15 +22,15 @@ namespace SourceGit.ViewModels public Models.DealWithLocalChanges PreAction { - get => _preAction; - set => SetProperty(ref _preAction, value); + get => _repo.Settings.DealWithLocalChangesOnCreateBranch; + set => _repo.Settings.DealWithLocalChangesOnCreateBranch = value; } public bool CheckoutAfterCreated { - get; - set; - } = true; + get => _repo.Settings.CheckoutBranchOnCreateBranch; + set => _repo.Settings.CheckoutBranchOnCreateBranch = value; + } public CreateBranch(Repository repo, Models.Branch branch) { @@ -89,7 +89,7 @@ namespace SourceGit.ViewModels bool needPopStash = false; if (_repo.WorkingCopyChangesCount > 0) { - if (_preAction == Models.DealWithLocalChanges.StashAndReaply) + if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { SetProgressDescription("Adding untracked changes..."); var succ = new Commands.Add(_repo.FullPath).Exec(); @@ -107,7 +107,7 @@ namespace SourceGit.ViewModels needPopStash = true; } - else if (_preAction == Models.DealWithLocalChanges.Discard) + else if (PreAction == Models.DealWithLocalChanges.Discard) { SetProgressDescription("Discard local changes..."); Commands.Discard.All(_repo.FullPath); @@ -137,6 +137,5 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private string _name = null; private readonly string _baseOnRevision = null; - private Models.DealWithLocalChanges _preAction = Models.DealWithLocalChanges.DoNothing; } } diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index 3b33bbf2..437bef70 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -30,9 +30,9 @@ namespace SourceGit.ViewModels public bool NoTags { - get; - set; - } = false; + get => _repo.Settings.FetchWithoutTags; + set => _repo.Settings.FetchWithoutTags = value; + } public Fetch(Repository repo, Models.Remote preferedRemote = null) { @@ -45,6 +45,7 @@ namespace SourceGit.ViewModels public override Task Sure() { _repo.SetWatcherEnabled(false); + return Task.Run(() => { if (FetchAllRemotes) diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index c210017f..743315fa 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -49,8 +49,8 @@ namespace SourceGit.ViewModels public Models.DealWithLocalChanges PreAction { - get => _preAction; - set => SetProperty(ref _preAction, value); + get => _repo.Settings.DealWithLocalChangesOnPull; + set => _repo.Settings.DealWithLocalChangesOnPull = value; } public bool UseRebase @@ -61,9 +61,9 @@ namespace SourceGit.ViewModels public bool NoTags { - get; - set; - } = false; + get => _repo.Settings.FetchWithoutTagsOnPull; + set => _repo.Settings.FetchWithoutTagsOnPull = value; + } public Pull(Repository repo, Models.Branch specifiedRemoteBranch) { @@ -120,12 +120,13 @@ namespace SourceGit.ViewModels public override Task Sure() { _repo.SetWatcherEnabled(false); + return Task.Run(() => { var needPopStash = false; if (_repo.WorkingCopyChangesCount > 0) { - if (_preAction == Models.DealWithLocalChanges.StashAndReaply) + if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { SetProgressDescription("Adding untracked changes..."); var succ = new Commands.Add(_repo.FullPath).Exec(); @@ -143,7 +144,7 @@ namespace SourceGit.ViewModels needPopStash = true; } - else if (_preAction == Models.DealWithLocalChanges.Discard) + else if (PreAction == Models.DealWithLocalChanges.Discard) { SetProgressDescription("Discard local changes ..."); Commands.Discard.All(_repo.FullPath); @@ -168,6 +169,5 @@ namespace SourceGit.ViewModels private Models.Remote _selectedRemote = null; private List _remoteBranches = null; private Models.Branch _selectedBranch = null; - private Models.DealWithLocalChanges _preAction = Models.DealWithLocalChanges.DoNothing; } } diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index 863ef873..12adca35 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -64,8 +64,8 @@ namespace SourceGit.ViewModels public bool PushAllTags { - get; - set; + get => _repo.Settings.PushAllTags; + set => _repo.Settings.PushAllTags = value; } public bool IsSetTrackOptionVisible diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 0a51c384..cdd2371a 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -14,14 +14,56 @@ using CommunityToolkit.Mvvm.ComponentModel; namespace SourceGit.ViewModels { - public class RepositorySettings : ObservableObject + public class RepositorySettings { + public Models.DealWithLocalChanges DealWithLocalChangesOnCheckoutBranch + { + get; + set; + } = Models.DealWithLocalChanges.DoNothing; + + public bool FetchWithoutTags + { + get; + set; + } = false; + + public Models.DealWithLocalChanges DealWithLocalChangesOnPull + { + get; + set; + } = Models.DealWithLocalChanges.DoNothing; + public bool PreferRebaseInsteadOfMerge { get; set; } = true; + public bool FetchWithoutTagsOnPull + { + get; + set; + } = false; + + public bool PushAllTags + { + get; + set; + } = false; + + public Models.DealWithLocalChanges DealWithLocalChangesOnCreateBranch + { + get; + set; + } = Models.DealWithLocalChanges.DoNothing; + + public bool CheckoutBranchOnCreateBranch + { + get; + set; + } = true; + public AvaloniaList Filters { get;