mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
refactor: commit search
* no longer depends on the commits displayed in histories view * limit the number of commits returned by all search methods to a maximum of 1000
This commit is contained in:
parent
48e1de809b
commit
c90abd0ca2
3 changed files with 24 additions and 22 deletions
|
@ -14,17 +14,22 @@ namespace SourceGit.Commands
|
|||
_findFirstMerged = needFindHead;
|
||||
}
|
||||
|
||||
public QueryCommits(string repo, int maxCount, string messageFilter, bool isFile)
|
||||
public QueryCommits(string repo, string filter, Models.CommitSearchMethod method)
|
||||
{
|
||||
string search;
|
||||
if (isFile)
|
||||
|
||||
if (method == Models.CommitSearchMethod.ByUser)
|
||||
{
|
||||
search = $"-- \"{messageFilter}\"";
|
||||
search = $"-i --author=\"{filter}\" --committer=\"{filter}\"";
|
||||
}
|
||||
else if (method == Models.CommitSearchMethod.ByFile)
|
||||
{
|
||||
search = $"-- \"{filter}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
var argsBuilder = new StringBuilder();
|
||||
var words = messageFilter.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var words = filter.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var word in words)
|
||||
{
|
||||
var escaped = word.Trim().Replace("\"", "\\\"", StringComparison.Ordinal);
|
||||
|
@ -36,7 +41,7 @@ namespace SourceGit.Commands
|
|||
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = $"log -{maxCount} --date-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 --branches --remotes " + search;
|
||||
Args = $"log -1000 --date-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 --branches --remotes " + search;
|
||||
_findFirstMerged = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue