mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
feature: supports search commit only in current branch
This commit is contained in:
parent
027844f4c5
commit
130c98ad40
14 changed files with 47 additions and 36 deletions
|
@ -14,21 +14,23 @@ namespace SourceGit.Commands
|
|||
_findFirstMerged = needFindHead;
|
||||
}
|
||||
|
||||
public QueryCommits(string repo, string filter, Models.CommitSearchMethod method)
|
||||
public QueryCommits(string repo, string filter, Models.CommitSearchMethod method, bool onlyCurrentBranch)
|
||||
{
|
||||
string search;
|
||||
string search = onlyCurrentBranch ? string.Empty : "--branches --remotes ";
|
||||
|
||||
if (method == Models.CommitSearchMethod.ByUser)
|
||||
{
|
||||
search = $"-i --author=\"{filter}\" --committer=\"{filter}\"";
|
||||
search += $"-i --author=\"{filter}\" --committer=\"{filter}\"";
|
||||
}
|
||||
else if (method == Models.CommitSearchMethod.ByFile)
|
||||
{
|
||||
search = $"-- \"{filter}\"";
|
||||
search += $"-- \"{filter}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
var argsBuilder = new StringBuilder();
|
||||
argsBuilder.Append(search);
|
||||
|
||||
var words = filter.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var word in words)
|
||||
{
|
||||
|
@ -36,12 +38,13 @@ namespace SourceGit.Commands
|
|||
argsBuilder.Append($"--grep=\"{escaped}\" ");
|
||||
}
|
||||
argsBuilder.Append("--all-match -i");
|
||||
|
||||
search = argsBuilder.ToString();
|
||||
}
|
||||
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
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;
|
||||
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 " + search;
|
||||
_findFirstMerged = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -512,7 +512,6 @@
|
|||
<x:String x:Key="Text.Repository.Remotes.Add" xml:space="preserve">REMOTE HINZUFÜGEN</x:String>
|
||||
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">KONFLIKTE BEHEBEN</x:String>
|
||||
<x:String x:Key="Text.Repository.Search" xml:space="preserve">Commit suchen</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">Suche über</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">Dateiname</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">Commit-Nachricht</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">SHA</x:String>
|
||||
|
|
|
@ -509,11 +509,11 @@
|
|||
<x:String x:Key="Text.Repository.Remotes.Add" xml:space="preserve">ADD REMOTE</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.By" xml:space="preserve">Search By</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.Search.InCurrentBranch" xml:space="preserve">Current Branch</x:String>
|
||||
<x:String x:Key="Text.Repository.ShowTagsAsTree" xml:space="preserve">Show Tags as Tree</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>
|
||||
|
|
|
@ -491,7 +491,6 @@
|
|||
<x:String x:Key="Text.Repository.Remotes.Add" xml:space="preserve">ADD REMOTE</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.By" xml:space="preserve">Search By</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>
|
||||
|
|
|
@ -484,7 +484,6 @@
|
|||
<x:String x:Key="Text.Repository.Remotes.Add" xml:space="preserve">ADICIONAR REMOTO</x:String>
|
||||
<x:String x:Key="Text.Repository.Resolve" xml:space="preserve">RESOLVER</x:String>
|
||||
<x:String x:Key="Text.Repository.Search" xml:space="preserve">Pesquisar Commit</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.By" xml:space="preserve">Pesquisar Por</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByFile" xml:space="preserve">Arquivo</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.ByMessage" xml:space="preserve">Mensagem</x:String>
|
||||
<x:String x:Key="Text.Repository.Search.BySHA" xml:space="preserve">SHA</x:String>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="avares://SourceGit/Resources/Locales/en_US.axaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<x:String x:Key="Text.About" xml:space="preserve">О программе</x:String>
|
||||
<x:String x:Key="Text.About.Menu" xml:space="preserve">О SourceGit</x:String>
|
||||
<x:String x:Key="Text.About.BuildWith" xml:space="preserve">• Сборка с </x:String>
|
||||
|
@ -507,7 +510,6 @@
|
|||
<x:String x:Key="Text.Repository.Remotes.Add" 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.By" 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">SHA</x:String>
|
||||
|
|
|
@ -507,11 +507,11 @@
|
|||
<x:String x:Key="Text.Repository.Remotes.Add" 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.By" 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.Search.InCurrentBranch" xml:space="preserve">仅在当前分支中查找</x:String>
|
||||
<x:String x:Key="Text.Repository.ShowTagsAsTree" 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>
|
||||
|
|
|
@ -512,11 +512,11 @@
|
|||
<x:String x:Key="Text.Repository.Remotes.Add" 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.By" 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.Search.InCurrentBranch" xml:space="preserve">僅搜尋當前分支</x:String>
|
||||
<x:String x:Key="Text.Repository.ShowTagsAsTree" 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>
|
||||
|
|
|
@ -544,7 +544,8 @@ namespace SourceGit.ViewModels
|
|||
private void TryToAddContextMenuItemsForGitLFS(ContextMenu menu, string path)
|
||||
{
|
||||
var lfsEnabled = new Commands.LFS(_repo.FullPath).IsEnabled();
|
||||
if (!lfsEnabled) return;
|
||||
if (!lfsEnabled)
|
||||
return;
|
||||
|
||||
var lfs = new MenuItem();
|
||||
lfs.Header = App.Text("GitLFS");
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace SourceGit.ViewModels
|
|||
CallUIThread(() =>
|
||||
{
|
||||
_repo.MarkFetched();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
_repo.SetWatcherEnabled(true);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace SourceGit.ViewModels
|
|||
get => _isLoading;
|
||||
private set => SetProperty(ref _isLoading, value);
|
||||
}
|
||||
|
||||
|
||||
public bool ShowOnlyMyLocks
|
||||
{
|
||||
get => _showOnlyMyLocks;
|
||||
|
|
|
@ -210,6 +210,12 @@ namespace SourceGit.ViewModels
|
|||
private set => SetProperty(ref _isSearchLoadingVisible, value);
|
||||
}
|
||||
|
||||
public bool OnlySearchCommitsInCurrentBranch
|
||||
{
|
||||
get => _onlySearchCommitsInCurrentBranch;
|
||||
set => SetProperty(ref _onlySearchCommitsInCurrentBranch, value);
|
||||
}
|
||||
|
||||
public int SearchCommitFilterType
|
||||
{
|
||||
get => _searchCommitFilterType;
|
||||
|
@ -589,13 +595,13 @@ namespace SourceGit.ViewModels
|
|||
visible.Add(commit);
|
||||
break;
|
||||
case 1:
|
||||
visible = new Commands.QueryCommits(_fullpath, _searchCommitFilter, Models.CommitSearchMethod.ByUser).Result();
|
||||
visible = new Commands.QueryCommits(_fullpath, _searchCommitFilter, Models.CommitSearchMethod.ByUser, _onlySearchCommitsInCurrentBranch).Result();
|
||||
break;
|
||||
case 2:
|
||||
visible = new Commands.QueryCommits(_fullpath, _searchCommitFilter, Models.CommitSearchMethod.ByMessage).Result();
|
||||
visible = new Commands.QueryCommits(_fullpath, _searchCommitFilter, Models.CommitSearchMethod.ByMessage, _onlySearchCommitsInCurrentBranch).Result();
|
||||
break;
|
||||
case 3:
|
||||
visible = new Commands.QueryCommits(_fullpath, _searchCommitFilter, Models.CommitSearchMethod.ByFile).Result();
|
||||
visible = new Commands.QueryCommits(_fullpath, _searchCommitFilter, Models.CommitSearchMethod.ByFile, _onlySearchCommitsInCurrentBranch).Result();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -667,8 +673,8 @@ namespace SourceGit.ViewModels
|
|||
var hasLeft = false;
|
||||
foreach (var b in _branches)
|
||||
{
|
||||
if (!b.FullName.Equals(local.FullName, StringComparison.Ordinal) &&
|
||||
!b.FullName.Equals(local.Upstream, StringComparison.Ordinal) &&
|
||||
if (!b.FullName.Equals(local.FullName, StringComparison.Ordinal) &&
|
||||
!b.FullName.Equals(local.Upstream, StringComparison.Ordinal) &&
|
||||
!_settings.Filters.Contains(b.FullName))
|
||||
{
|
||||
hasLeft = true;
|
||||
|
@ -2072,6 +2078,7 @@ namespace SourceGit.ViewModels
|
|||
private bool _isSearchLoadingVisible = false;
|
||||
private bool _isSearchCommitSuggestionOpen = false;
|
||||
private int _searchCommitFilterType = 2;
|
||||
private bool _onlySearchCommitsInCurrentBranch = false;
|
||||
private bool _enableFirstParentInHistories = false;
|
||||
private string _searchCommitFilter = string.Empty;
|
||||
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
||||
|
|
|
@ -430,7 +430,7 @@ namespace SourceGit.Views
|
|||
|
||||
private void OnToggleFilterClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo &&
|
||||
if (DataContext is ViewModels.Repository repo &&
|
||||
sender is ToggleButton toggle &&
|
||||
toggle.DataContext is ViewModels.BranchTreeNode { Backend: Models.Branch branch } node)
|
||||
{
|
||||
|
|
|
@ -343,7 +343,7 @@
|
|||
</Grid>
|
||||
|
||||
<!-- Commit Search Panel -->
|
||||
<Grid Grid.Row="1" RowDefinitions="24,32,*" Margin="8,0,4,8" IsVisible="{Binding IsSearching}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
|
||||
<Grid Grid.Row="1" RowDefinitions="26,26,*" Margin="8,0,4,8" IsVisible="{Binding IsSearching}" PropertyChanged="OnSearchCommitPanelPropertyChanged">
|
||||
<!-- Search Input Box -->
|
||||
<Grid Grid.Row="0">
|
||||
<TextBox x:Name="TxtSearchCommitsBox"
|
||||
|
@ -430,18 +430,11 @@
|
|||
</Popup>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="{DynamicResource Text.Repository.Search.By}"
|
||||
Foreground="{DynamicResource Brush.FG2}"
|
||||
Margin="2,0,0,0"/>
|
||||
|
||||
<ComboBox Grid.Column="1"
|
||||
MinHeight="24" Height="24"
|
||||
Padding="8,0"
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
HorizontalAlignment="Right"
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<ComboBox MinHeight="24" Height="24"
|
||||
Padding="4,0"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
SelectedIndex="{Binding SearchCommitFilterType, Mode=TwoWay}">
|
||||
<ComboBox.Items>
|
||||
<TextBlock Text="{DynamicResource Text.Repository.Search.BySHA}" FontSize="12"/>
|
||||
|
@ -450,9 +443,17 @@
|
|||
<TextBlock Text="{DynamicResource Text.Repository.Search.ByFile}" FontSize="12"/>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
|
||||
|
||||
<CheckBox Height="24"
|
||||
Margin="4,0,0,0"
|
||||
FontSize="12"
|
||||
Content="{DynamicResource Text.Repository.Search.InCurrentBranch}"
|
||||
IsChecked="{Binding OnlySearchCommitsInCurrentBranch, Mode=TwoWay}"
|
||||
IsVisible="{Binding SearchCommitFilterType, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
|
||||
</StackPanel>
|
||||
|
||||
<ListBox Grid.Row="2"
|
||||
Margin="0,8,0,0"
|
||||
ItemsSource="{Binding SearchedCommits}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{Binding SearchResultSelectedCommit, Mode=TwoWay}"
|
||||
|
|
Loading…
Reference in a new issue