refactor: move settings of repository, such as filters, commit message, from Preference to each repository's gitdir.

* avoid invalid repository setting remains in preference.json
* supports to restore tabs that not added to the Welcome page
This commit is contained in:
leo 2024-07-01 11:57:13 +08:00
parent 56a42dd6e8
commit 7f389b2e6f
No known key found for this signature in database
18 changed files with 187 additions and 209 deletions

View file

@ -1113,7 +1113,7 @@ namespace SourceGit.ViewModels
public ContextMenu CreateContextMenuForCommitMessages()
{
var menu = new ContextMenu();
if (_repo.CommitMessages.Count == 0)
if (_repo.Settings.CommitMessages.Count == 0)
{
var empty = new MenuItem();
empty.Header = App.Text("WorkingCopy.NoCommitHistories");
@ -1128,7 +1128,7 @@ namespace SourceGit.ViewModels
menu.Items.Add(tip);
menu.Items.Add(new MenuItem() { Header = "-" });
foreach (var message in _repo.CommitMessages)
foreach (var message in _repo.Settings.CommitMessages)
{
var dump = message;
@ -1228,7 +1228,7 @@ namespace SourceGit.ViewModels
return;
}
PushCommitMessage();
_repo.Settings.PushCommitMessage(_commitMessage);
SetDetail(null);
IsCommitting = true;
@ -1257,27 +1257,6 @@ namespace SourceGit.ViewModels
});
}
private void PushCommitMessage()
{
var existIdx = _repo.CommitMessages.IndexOf(CommitMessage);
if (existIdx == 0)
{
return;
}
else if (existIdx > 0)
{
_repo.CommitMessages.Move(existIdx, 0);
return;
}
if (_repo.CommitMessages.Count > 9)
{
_repo.CommitMessages.RemoveRange(9, _repo.CommitMessages.Count - 9);
}
_repo.CommitMessages.Insert(0, CommitMessage);
}
private Repository _repo = null;
private bool _isLoadingData = false;
private bool _isStaging = false;