mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -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;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace SourceGit.Commands
|
namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
|
@ -9,10 +10,27 @@ namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
WorkingDirectory = repo;
|
WorkingDirectory = repo;
|
||||||
Context = 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;
|
_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()
|
public List<Models.Commit> Result()
|
||||||
{
|
{
|
||||||
var rs = ReadToEnd();
|
var rs = ReadToEnd();
|
||||||
|
|
|
@ -566,7 +566,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
visible = new Commands.QueryCommits(FullPath, $"-1000 --grep=\"{_searchCommitFilter}\"", false).Result();
|
visible = new Commands.QueryCommits(FullPath, 1000, _searchCommitFilter).Result();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
|
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
|
||||||
|
|
Loading…
Reference in a new issue