mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: remember --reflog
, --first-parent
, --topo-order
and --date-order
toggle states
This commit is contained in:
parent
ed3e7cbfaf
commit
37bf6dec5e
4 changed files with 57 additions and 28 deletions
|
@ -6,13 +6,11 @@ namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
public class QueryCommits : Command
|
public class QueryCommits : Command
|
||||||
{
|
{
|
||||||
public QueryCommits(string repo, bool useTopoOrder, string limits, bool needFindHead = true)
|
public QueryCommits(string repo, string limits, bool needFindHead = true)
|
||||||
{
|
{
|
||||||
var order = useTopoOrder ? "--topo-order" : "--date-order";
|
|
||||||
|
|
||||||
WorkingDirectory = repo;
|
WorkingDirectory = repo;
|
||||||
Context = repo;
|
Context = repo;
|
||||||
Args = $"log {order} --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s {limits}";
|
Args = $"log --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s {limits}";
|
||||||
_findFirstMerged = needFindHead;
|
_findFirstMerged = needFindHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,24 @@ namespace SourceGit.Models
|
||||||
set;
|
set;
|
||||||
} = string.Empty;
|
} = string.Empty;
|
||||||
|
|
||||||
|
public bool EnableReflog
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = false;
|
||||||
|
|
||||||
|
public bool EnableFirstParentInHistories
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = false;
|
||||||
|
|
||||||
|
public bool EnableTopoOrderInHistories
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = false;
|
||||||
|
|
||||||
public bool IncludeUntrackedInLocalChanges
|
public bool IncludeUntrackedInLocalChanges
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace SourceGit.ViewModels
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var based = commit ?? string.Empty;
|
var based = commit ?? string.Empty;
|
||||||
var commits = new Commands.QueryCommits(_repo.FullPath, false, $"-n 10000 {based} -- \"{file}\"", false).Result();
|
var commits = new Commands.QueryCommits(_repo.FullPath, $"--date-order -n 10000 {based} -- \"{file}\"", false).Result();
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
|
|
@ -88,31 +88,43 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public bool EnableReflog
|
public bool EnableReflog
|
||||||
{
|
{
|
||||||
get => _enableReflog;
|
get => _settings.EnableReflog;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (SetProperty(ref _enableReflog, value))
|
if (value != _settings.EnableReflog)
|
||||||
|
{
|
||||||
|
_settings.EnableReflog = value;
|
||||||
|
OnPropertyChanged();
|
||||||
Task.Run(RefreshCommits);
|
Task.Run(RefreshCommits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EnableFirstParentInHistories
|
public bool EnableFirstParentInHistories
|
||||||
{
|
{
|
||||||
get => _enableFirstParentInHistories;
|
get => _settings.EnableFirstParentInHistories;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (SetProperty(ref _enableFirstParentInHistories, value))
|
if (value != _settings.EnableFirstParentInHistories)
|
||||||
|
{
|
||||||
|
_settings.EnableFirstParentInHistories = value;
|
||||||
|
OnPropertyChanged();
|
||||||
Task.Run(RefreshCommits);
|
Task.Run(RefreshCommits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EnableTopoOrderInHistories
|
public bool EnableTopoOrderInHistories
|
||||||
{
|
{
|
||||||
get => _enableTopoOrderInHistories;
|
get => _settings.EnableTopoOrderInHistories;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (SetProperty(ref _enableTopoOrderInHistories, value))
|
if (value != _settings.EnableTopoOrderInHistories)
|
||||||
|
{
|
||||||
|
_settings.EnableTopoOrderInHistories = value;
|
||||||
|
OnPropertyChanged();
|
||||||
Task.Run(RefreshCommits);
|
Task.Run(RefreshCommits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,8 +263,7 @@ namespace SourceGit.ViewModels
|
||||||
get => _onlySearchCommitsInCurrentBranch;
|
get => _onlySearchCommitsInCurrentBranch;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (SetProperty(ref _onlySearchCommitsInCurrentBranch, value) &&
|
if (SetProperty(ref _onlySearchCommitsInCurrentBranch, value) && !string.IsNullOrEmpty(_searchCommitFilter))
|
||||||
!string.IsNullOrEmpty(_searchCommitFilter))
|
|
||||||
StartSearchCommits();
|
StartSearchCommits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,8 +417,8 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public bool IsAutoFetching
|
public bool IsAutoFetching
|
||||||
{
|
{
|
||||||
get;
|
get => _isAutoFetching;
|
||||||
private set;
|
private set => SetProperty(ref _isAutoFetching, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Open()
|
public void Open()
|
||||||
|
@ -883,9 +894,15 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
builder.Append($"-{Preference.Instance.MaxHistoryCommits} ");
|
builder.Append($"-{Preference.Instance.MaxHistoryCommits} ");
|
||||||
if (_enableReflog)
|
|
||||||
|
if (_settings.EnableTopoOrderInHistories)
|
||||||
|
builder.Append("--topo-order ");
|
||||||
|
else
|
||||||
|
builder.Append("--date-order ");
|
||||||
|
|
||||||
|
if (_settings.EnableReflog)
|
||||||
builder.Append("--reflog ");
|
builder.Append("--reflog ");
|
||||||
if (_enableFirstParentInHistories)
|
if (_settings.EnableFirstParentInHistories)
|
||||||
builder.Append("--first-parent ");
|
builder.Append("--first-parent ");
|
||||||
|
|
||||||
var filters = _settings.BuildHistoriesFilter();
|
var filters = _settings.BuildHistoriesFilter();
|
||||||
|
@ -894,8 +911,8 @@ namespace SourceGit.ViewModels
|
||||||
else
|
else
|
||||||
builder.Append(filters);
|
builder.Append(filters);
|
||||||
|
|
||||||
var commits = new Commands.QueryCommits(_fullpath, _enableTopoOrderInHistories, builder.ToString()).Result();
|
var commits = new Commands.QueryCommits(_fullpath, builder.ToString()).Result();
|
||||||
var graph = Models.CommitGraph.Parse(commits, _enableFirstParentInHistories);
|
var graph = Models.CommitGraph.Parse(commits, _settings.EnableFirstParentInHistories);
|
||||||
|
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
|
@ -2243,7 +2260,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
private void AutoFetchImpl(object sender)
|
private void AutoFetchImpl(object sender)
|
||||||
{
|
{
|
||||||
if (!_settings.EnableAutoFetch || IsAutoFetching)
|
if (!_settings.EnableAutoFetch || _isAutoFetching)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var lockFile = Path.Combine(_gitDir, "index.lock");
|
var lockFile = Path.Combine(_gitDir, "index.lock");
|
||||||
|
@ -2255,12 +2272,10 @@ namespace SourceGit.ViewModels
|
||||||
if (desire > now)
|
if (desire > now)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IsAutoFetching = true;
|
Dispatcher.UIThread.Invoke(() => IsAutoFetching = true);
|
||||||
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
|
||||||
new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, false, null) { RaiseError = false }.Exec();
|
new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, false, null) { RaiseError = false }.Exec();
|
||||||
_lastFetchTime = DateTime.Now;
|
_lastFetchTime = DateTime.Now;
|
||||||
IsAutoFetching = false;
|
Dispatcher.UIThread.Invoke(() => IsAutoFetching = false);
|
||||||
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _fullpath = string.Empty;
|
private string _fullpath = string.Empty;
|
||||||
|
@ -2284,11 +2299,9 @@ namespace SourceGit.ViewModels
|
||||||
private bool _isSearchCommitSuggestionOpen = false;
|
private bool _isSearchCommitSuggestionOpen = false;
|
||||||
private int _searchCommitFilterType = 2;
|
private int _searchCommitFilterType = 2;
|
||||||
private bool _onlySearchCommitsInCurrentBranch = false;
|
private bool _onlySearchCommitsInCurrentBranch = false;
|
||||||
private bool _enableReflog = false;
|
|
||||||
private bool _enableFirstParentInHistories = false;
|
|
||||||
private bool _enableTopoOrderInHistories = false;
|
|
||||||
private string _searchCommitFilter = string.Empty;
|
private string _searchCommitFilter = string.Empty;
|
||||||
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
||||||
|
private Models.Commit _searchResultSelectedCommit = null;
|
||||||
private List<string> _revisionFiles = new List<string>();
|
private List<string> _revisionFiles = new List<string>();
|
||||||
|
|
||||||
private string _filter = string.Empty;
|
private string _filter = string.Empty;
|
||||||
|
@ -2303,7 +2316,7 @@ namespace SourceGit.ViewModels
|
||||||
private List<Models.Submodule> _submodules = new List<Models.Submodule>();
|
private List<Models.Submodule> _submodules = new List<Models.Submodule>();
|
||||||
private List<Models.Submodule> _visibleSubmodules = new List<Models.Submodule>();
|
private List<Models.Submodule> _visibleSubmodules = new List<Models.Submodule>();
|
||||||
|
|
||||||
private Models.Commit _searchResultSelectedCommit = null;
|
private bool _isAutoFetching = false;
|
||||||
private Timer _autoFetchTimer = null;
|
private Timer _autoFetchTimer = null;
|
||||||
private DateTime _lastFetchTime = DateTime.MinValue;
|
private DateTime _lastFetchTime = DateTime.MinValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue