mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: search commits by message (#256)
This commit is contained in:
parent
3aad24a64e
commit
8e7bfc43e0
3 changed files with 20 additions and 3 deletions
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
|
@ -9,10 +10,27 @@ namespace SourceGit.Commands
|
|||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = $"log --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 " + limits;
|
||||
Args = "log --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 " + limits;
|
||||
_findFirstMerged = needFindHead;
|
||||
}
|
||||
|
||||
public QueryCommits(string repo, int maxCount, string messageFilter)
|
||||
{
|
||||
var argsBuilder = new StringBuilder();
|
||||
var words = messageFilter.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var word in words)
|
||||
{
|
||||
var escaped = word.Trim().Replace("\"", "\\\"", StringComparison.Ordinal);
|
||||
argsBuilder.Append($"--grep=\"{escaped}\" ");
|
||||
}
|
||||
argsBuilder.Append("--all-match");
|
||||
|
||||
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 " + argsBuilder.ToString();
|
||||
_findFirstMerged = false;
|
||||
}
|
||||
|
||||
public List<Models.Commit> Result()
|
||||
{
|
||||
var rs = ReadToEnd();
|
||||
|
|
|
@ -566,7 +566,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
break;
|
||||
case 2:
|
||||
visible = new Commands.QueryCommits(FullPath, $"-1000 --grep=\"{_searchCommitFilter}\"", false).Result();
|
||||
visible = new Commands.QueryCommits(FullPath, 1000, _searchCommitFilter).Result();
|
||||
break;
|
||||
case 3:
|
||||
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
|
||||
|
|
Loading…
Reference in a new issue