mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
refactor: commit search (#256)
This commit is contained in:
parent
38c6c7713e
commit
6a8527a394
6 changed files with 37 additions and 20 deletions
|
@ -455,8 +455,10 @@
|
||||||
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">RESOLVE</x:String>
|
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">RESOLVE</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search" xml:space="preserve">Search Commit</x:String>
|
<x:String x:Key="Text.Repository.Search" xml:space="preserve">Search Commit</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">Search By</x:String>
|
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">Search By</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.ByBaseInfo" xml:space="preserve">Information</x:String>
|
|
||||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">File</x:String>
|
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">File</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">Message</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">SHA</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.ByUser" xml:space="preserve">Author & Committer</x:String>
|
||||||
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">Search Branches & Tags</x:String>
|
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">Search Branches & Tags</x:String>
|
||||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">Statistics</x:String>
|
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">Statistics</x:String>
|
||||||
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">SUBMODULES</x:String>
|
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">SUBMODULES</x:String>
|
||||||
|
|
|
@ -457,8 +457,10 @@
|
||||||
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">解决冲突</x:String>
|
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">解决冲突</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search" xml:space="preserve">查找提交</x:String>
|
<x:String x:Key="Text.Repository.Search" xml:space="preserve">查找提交</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">搜索途径</x:String>
|
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">搜索途径</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.ByBaseInfo" xml:space="preserve">摘要</x:String>
|
|
||||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">文件</x:String>
|
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">文件</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">提交信息</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">提交指纹</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.ByUser" xml:space="preserve">作者及提交者</x:String>
|
||||||
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">快速查找分支、标签</x:String>
|
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">快速查找分支、标签</x:String>
|
||||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交统计</x:String>
|
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交统计</x:String>
|
||||||
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">子模块列表</x:String>
|
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">子模块列表</x:String>
|
||||||
|
|
|
@ -457,8 +457,10 @@
|
||||||
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">解決衝突</x:String>
|
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">解決衝突</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search" xml:space="preserve">查詢提交</x:String>
|
<x:String x:Key="Text.Repository.Search" xml:space="preserve">查詢提交</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">查詢方式</x:String>
|
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">查詢方式</x:String>
|
||||||
<x:String x:Key="Text.Repository.Search.ByBaseInfo" xml:space="preserve">摘要</x:String>
|
|
||||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">檔案</x:String>
|
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">檔案</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">提交資訊</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">提交指紋</x:String>
|
||||||
|
<x:String x:Key="Text.Repository.Search.ByUser" xml:space="preserve">作者及提交者</x:String>
|
||||||
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">快速查找分支、標籤</x:String>
|
<x:String x:Key="Text.Repository.SearchBranchTag" xml:space="preserve">快速查找分支、標籤</x:String>
|
||||||
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交統計</x:String>
|
<x:String x:Key="Text.Repository.Statistics" xml:space="preserve">提交統計</x:String>
|
||||||
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">子模組列表</x:String>
|
<x:String x:Key="Text.Repository.Submodules" xml:space="preserve">子模組列表</x:String>
|
||||||
|
|
|
@ -545,24 +545,33 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
var visible = new List<Models.Commit>();
|
var visible = new List<Models.Commit>();
|
||||||
|
|
||||||
if (_searchCommitFilterType == 0)
|
switch (_searchCommitFilterType)
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
foreach (var c in _histories.Commits)
|
foreach (var c in _histories.Commits)
|
||||||
{
|
{
|
||||||
if (c.SHA.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
if (c.SHA.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase))
|
||||||
|| c.Subject.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
visible.Add(c);
|
||||||
|| c.Author.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
foreach (var c in _histories.Commits)
|
||||||
|
{
|
||||||
|
if (c.Author.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|| c.Committer.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
|| c.Committer.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|| c.Author.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
|| c.Author.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|| c.Committer.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase))
|
|| c.Committer.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
|
||||||
visible.Add(c);
|
visible.Add(c);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
break;
|
||||||
else
|
case 2:
|
||||||
{
|
visible = new Commands.QueryCommits(FullPath, $"-1000 --grep=\"{_searchCommitFilter}\"", false).Result();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
|
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
|
|
@ -580,7 +580,9 @@
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
SelectedIndex="{Binding SearchCommitFilterType, Mode=TwoWay}">
|
SelectedIndex="{Binding SearchCommitFilterType, Mode=TwoWay}">
|
||||||
<ComboBox.Items>
|
<ComboBox.Items>
|
||||||
<TextBlock Text="{DynamicResource Text.Repository.Search.ByBaseInfo}" FontSize="12"/>
|
<TextBlock Text="{DynamicResource Text.Repository.Search.BySHA}" FontSize="12"/>
|
||||||
|
<TextBlock Text="{DynamicResource Text.Repository.Search.ByUser}" FontSize="12"/>
|
||||||
|
<TextBlock Text="{DynamicResource Text.Repository.Search.ByMessage}" FontSize="12"/>
|
||||||
<TextBlock Text="{DynamicResource Text.Repository.Search.ByFile}" FontSize="12"/>
|
<TextBlock Text="{DynamicResource Text.Repository.Search.ByFile}" FontSize="12"/>
|
||||||
</ComboBox.Items>
|
</ComboBox.Items>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
if (DataContext is ViewModels.Repository repo)
|
if (DataContext is ViewModels.Repository repo && !string.IsNullOrWhiteSpace(repo.SearchCommitFilter))
|
||||||
repo.StartSearchCommits();
|
repo.StartSearchCommits();
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
Loading…
Reference in a new issue