Compare commits

...

10 commits

Author SHA1 Message Date
leo
4b6bb70f20
fix: parent commit's tooltip does not close when move mouse out of bound fast
Some checks failed
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
Localization Check / localization-check (push) Has been cancelled
Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 16:04:42 +08:00
leo
bd85b41da7
ux: clear histories filter button style
Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 14:50:18 +08:00
leo
5861482455
fix: wrong format
Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 11:55:18 +08:00
leo
30741b0f25
project: upgrade dependencies
* upgrade Avalonia to 11.1.4
* upgrade LiveChartsCore.SkiaSharpView.Avalonia to 2.0.0-rc4.5
* upgrade TextMateSharp to 1.0.64

Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 11:51:13 +08:00
leo
e78b58cb81
localization: remove duplicated keys
Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 11:49:49 +08:00
leo
a5f37800f6
code_style: remove unused var
Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 10:52:39 +08:00
leo
4835c3f1e9
enhance: do NOT trigger double clicking events when user click the blank area of ListBox
Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 10:50:52 +08:00
leo
a5606e80d4
refactor: move codes from Views.FilterModeSwitchButton to ViewModels.Repository
Signed-off-by: leo <longshuang@msn.cn>
2024-11-15 10:19:39 +08:00
github-actions[bot]
66842b1d0d doc: Update translation status and missing keys 2024-11-15 01:19:12 +00:00
AquariusStar
63dfde7cb8
localization: update translation for russian (#700) 2024-11-15 09:18:55 +08:00
16 changed files with 215 additions and 260 deletions

View file

@ -47,7 +47,7 @@
## Translation Status
[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.57%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-99.14%25-yellow)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-98.42%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-99.14%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-99.57%25-yellow)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md)
[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.57%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-99.14%25-yellow)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-98.42%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-99.14%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-100.00%25-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md)
## How to Use

View file

@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{F45A
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{67B6D05F-A000-40BA-ADB4-C9065F880D7B}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\ci.yml = .github\workflows\ci.yml
.github\workflows\package.yml = .github\workflows\package.yml
.github\workflows\release.yml = .github\workflows\release.yml

View file

@ -60,15 +60,13 @@
</details>
### ru_RU.axaml: 99.57%
### ru_RU.axaml: 100.00%
<details>
<summary>Missing Keys</summary>
- Text.Repository.FilterCommits.Default
- Text.Repository.FilterCommits.Exclude
- Text.Repository.FilterCommits.Include
</details>

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text;
using Avalonia.Collections;
using Avalonia.Threading;
namespace SourceGit.Models
{
@ -218,10 +217,26 @@ namespace SourceGit.Models
return true;
}
public void RemoveChildrenBranchFilters(string pattern)
{
var dirty = new List<Filter>();
var prefix = $"{pattern}/";
foreach (var filter in HistoriesFilters)
{
if (filter.Type == FilterType.Tag)
continue;
if (filter.Pattern.StartsWith(prefix, StringComparison.Ordinal))
dirty.Add(filter);
}
foreach (var filter in dirty)
HistoriesFilters.Remove(filter);
}
public string BuildHistoriesFilter()
{
var builder = new StringBuilder();
var excludedBranches = new List<string>();
var excludedRemotes = new List<string>();
var excludedTags = new List<string>();
@ -276,14 +291,11 @@ namespace SourceGit.Models
}
}
foreach (var b in excludedBranches)
{
builder.Append("--exclude=");
builder.Append(b);
builder.Append(' ');
}
bool hasIncluded = includedBranches.Count > 0 || includedRemotes.Count > 0 || includedTags.Count > 0;
bool hasExcluded = excludedBranches.Count > 0 || excludedRemotes.Count > 0 || excludedTags.Count > 0;
if (includedBranches.Count > 0)
var builder = new StringBuilder();
if (hasIncluded)
{
foreach (var b in includedBranches)
{
@ -291,44 +303,14 @@ namespace SourceGit.Models
builder.Append(b);
builder.Append(' ');
}
}
else if (excludedBranches.Count > 0 || (includedRemotes.Count == 0 && includedTags.Count == 0))
{
builder.Append("--exclude=HEA[D] ");
builder.Append("--branches ");
}
foreach (var r in excludedRemotes)
{
builder.Append("--exclude=");
builder.Append(r);
builder.Append(' ');
}
if (includedRemotes.Count > 0)
{
foreach (var r in includedRemotes)
{
builder.Append("--remotes=");
builder.Append(r);
builder.Append(' ');
}
}
else if (excludedRemotes.Count > 0 || (includedBranches.Count == 0 && includedTags.Count == 0))
{
builder.Append("--exclude=origin/HEA[D] ");
builder.Append("--remotes ");
}
foreach (var t in excludedTags)
{
builder.Append("--exclude=");
builder.Append(t);
builder.Append(' ');
}
if (includedTags.Count > 0)
{
foreach (var t in includedTags)
{
builder.Append("--tags=");
@ -336,8 +318,42 @@ namespace SourceGit.Models
builder.Append(' ');
}
}
else if (excludedTags.Count > 0 || (includedBranches.Count == 0 && includedRemotes.Count == 0))
else if (hasExcluded)
{
if (excludedBranches.Count > 0)
{
foreach (var b in excludedBranches)
{
builder.Append("--exclude=");
builder.Append(b);
builder.Append(' ');
}
}
builder.Append("--exclude=HEA[D] --branches ");
if (excludedRemotes.Count > 0)
{
foreach (var r in excludedRemotes)
{
builder.Append("--exclude=");
builder.Append(r);
builder.Append(' ');
}
}
builder.Append("--exclude=origin/HEA[D] --remotes ");
if (excludedTags.Count > 0)
{
foreach (var t in excludedTags)
{
builder.Append("--exclude=");
builder.Append(t);
builder.Append(' ');
}
}
builder.Append("--tags ");
}

View file

@ -82,12 +82,11 @@
<x:String x:Key="Text.Checkout.Commit" xml:space="preserve">Checkout ce commit</x:String>
<x:String x:Key="Text.Checkout.Commit.Target" xml:space="preserve">Commit :</x:String>
<x:String x:Key="Text.Checkout.Commit.Warning" xml:space="preserve">Avertissement: un checkout vers un commit aboutiera vers un HEAD détaché</x:String>
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">Branche:</x:String>
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">Branche :</x:String>
<x:String x:Key="Text.Checkout.LocalChanges" xml:space="preserve">Changements locaux :</x:String>
<x:String x:Key="Text.Checkout.LocalChanges.Discard" xml:space="preserve">Annuler</x:String>
<x:String x:Key="Text.Checkout.LocalChanges.DoNothing" xml:space="preserve">Ne rien faire</x:String>
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReply" xml:space="preserve">Mettre en stash et réappliquer</x:String>
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">Branche :</x:String>
<x:String x:Key="Text.CherryPick" xml:space="preserve">Cherry-Pick de ce commit</x:String>
<x:String x:Key="Text.CherryPick.Commit" xml:space="preserve">Commit :</x:String>
<x:String x:Key="Text.CherryPick.CommitChanges" xml:space="preserve">Commit tous les changements</x:String>
@ -102,7 +101,6 @@
<x:String x:Key="Text.Clone.LocalName.Placeholder" xml:space="preserve">Nom de dépôt. Optionnel.</x:String>
<x:String x:Key="Text.Clone.ParentFolder" xml:space="preserve">Dossier parent :</x:String>
<x:String x:Key="Text.Clone.RemoteURL" xml:space="preserve">URL du dépôt :</x:String>
<x:String x:Key="Text.Clone" xml:space="preserve">Cloner le dépôt distant</x:String>
<x:String x:Key="Text.Close" xml:space="preserve">FERMER</x:String>
<x:String x:Key="Text.CodeEditor" xml:space="preserve">Éditeur</x:String>
<x:String x:Key="Text.CommitCM.Checkout" xml:space="preserve">Changer de commit</x:String>
@ -537,7 +535,6 @@
<x:String x:Key="Text.Repository.ClearAllCommitsFilter" xml:space="preserve">Tout effacer</x:String>
<x:String x:Key="Text.Repository.Configure" xml:space="preserve">Configurer ce repository</x:String>
<x:String x:Key="Text.Repository.Continue" xml:space="preserve">CONTINUER</x:String>
<x:String x:Key="Text.Repository.Explore" xml:space="preserve">Ouvrir dans l'explorateur Windows</x:String>
<x:String x:Key="Text.Repository.CustomActions.Empty" xml:space="preserve">Pas d'actions personnalisées</x:String>
<x:String x:Key="Text.Repository.EnableReflog" xml:space="preserve">Activer l'option '--reflog'</x:String>
<x:String x:Key="Text.Repository.Explore" xml:space="preserve">Ouvrir dans l'explorateur de fichiers</x:String>
@ -584,7 +581,6 @@
<x:String x:Key="Text.Save" xml:space="preserve">SAUVEGARDER</x:String>
<x:String x:Key="Text.SaveAs" xml:space="preserve">Sauvegarder en tant que...</x:String>
<x:String x:Key="Text.SaveAsPatchSuccess" xml:space="preserve">Le patch a été sauvegardé !</x:String>
<x:String x:Key="Text.SelfUpdate" xml:space="preserve">Vérifier les mises à jour...</x:String>
<x:String x:Key="Text.ScanRepositories.RootDir" xml:space="preserve">Dossier racine :</x:String>
<x:String x:Key="Text.SelfUpdate" xml:space="preserve">Rechercher des mises à jour...</x:String>
<x:String x:Key="Text.SelfUpdate.Available" xml:space="preserve">Une nouvelle version du logiciel est disponible :</x:String>

View file

@ -176,7 +176,6 @@
<x:String x:Key="Text.Configure.CustomAction.Scope.Repository" xml:space="preserve">Repositório</x:String>
<x:String x:Key="Text.Configure.Email" xml:space="preserve">Endereço de email</x:String>
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Endereço de email</x:String>
<x:String x:Key="Text.Configure.Email" xml:space="preserve">Endereço de Email</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Buscar remotos automaticamente</x:String>
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minuto(s)</x:String>
<x:String x:Key="Text.Configure.Git.DefaultRemote" xml:space="preserve">Remoto padrão</x:String>

View file

@ -62,7 +62,7 @@
<x:String x:Key="Text.BranchCM.Finish" xml:space="preserve">Поток Git - Завершение ${0}$</x:String>
<x:String x:Key="Text.BranchCM.Merge" xml:space="preserve">Слить ${0}$ в ${1}$...</x:String>
<x:String x:Key="Text.BranchCM.Pull" xml:space="preserve">Забрать ${0}$</x:String>
<x:String x:Key="Text.BranchCM.PullInto" xml:space="preserve">Перетащить ${0}$ в ${1}$...</x:String>
<x:String x:Key="Text.BranchCM.PullInto" xml:space="preserve">Забрать ${0}$ в ${1}$...</x:String>
<x:String x:Key="Text.BranchCM.Push" xml:space="preserve">Выложить ${0}$</x:String>
<x:String x:Key="Text.BranchCM.Rebase" xml:space="preserve">Переместить ${0}$ на ${1}$...</x:String>
<x:String x:Key="Text.BranchCM.Rename" xml:space="preserve">Переименовать ${0}$...</x:String>
@ -213,7 +213,7 @@
<x:String x:Key="Text.CreateTag.Type" xml:space="preserve">Вид:</x:String>
<x:String x:Key="Text.CreateTag.Type.Annotated" xml:space="preserve">Аннотированный</x:String>
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">Лёгкий</x:String>
<x:String x:Key="Text.CtrlClickTip" xml:space="preserve">Удерживайте Ctrl, чтобы начать непосредственно</x:String>
<x:String x:Key="Text.CtrlClickTip" xml:space="preserve">Удерживайте Ctrl, чтобы начать сразу</x:String>
<x:String x:Key="Text.Cut" xml:space="preserve">Вырезать</x:String>
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">Удалить ветку</x:String>
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">Ветка:</x:String>
@ -368,11 +368,11 @@
<x:String x:Key="Text.Hotkeys.Repo.CommitWithAutoStage" xml:space="preserve">Подготовить все изменения и зафиксировать</x:String>
<x:String x:Key="Text.Hotkeys.Repo.CreateBranchOnCommit" xml:space="preserve">Создать новую ветку на основе выбранной ветки</x:String>
<x:String x:Key="Text.Hotkeys.Repo.DiscardSelected" xml:space="preserve">Отклонить выбранные изменения</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Fetch" xml:space="preserve">Извлечение, запускается непосредственно</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Fetch" xml:space="preserve">Извлечение, запускается сразу</x:String>
<x:String x:Key="Text.Hotkeys.Repo.GoHome" xml:space="preserve">Режим доски (по-умолчанию)</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Refresh" xml:space="preserve">Принудительно перезагрузить этот хранилище</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Pull" xml:space="preserve">Забрать, запускается непосредственно</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Push" xml:space="preserve">Выложить, запускается непосредственно</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Pull" xml:space="preserve">Забрать, запускается сразу</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Push" xml:space="preserve">Выложить, запускается сразу</x:String>
<x:String x:Key="Text.Hotkeys.Repo.StageOrUnstageSelected" xml:space="preserve">Подготовленные/Неподготовленные выбранные изменения</x:String>
<x:String x:Key="Text.Hotkeys.Repo.OpenSearchCommits" xml:space="preserve">Режим поиска фиксаций</x:String>
<x:String x:Key="Text.Hotkeys.Repo.ViewChanges" xml:space="preserve">Переключить на «Изменения»</x:String>
@ -544,6 +544,10 @@
<x:String x:Key="Text.Repository.EnableReflog" xml:space="preserve">Разрешить опцию --reflog</x:String>
<x:String x:Key="Text.Repository.Explore" xml:space="preserve">Открыть в файловом менеджере</x:String>
<x:String x:Key="Text.Repository.Filter" xml:space="preserve">Поиск веток, меток и подмодулей</x:String>
<x:String x:Key="Text.Repository.FilterCommits.Default" xml:space="preserve">Не установлен (По-умолчанию)</x:String>
<x:String x:Key="Text.Repository.FilterCommits.Exclude" xml:space="preserve">Скрыть в графе фиксации</x:String>
<x:String x:Key="Text.Repository.FilterCommits.Include" xml:space="preserve">Фильтр в графе фиксации</x:String>
<x:String x:Key="Text.Repository.FilterCommits.Prefix" xml:space="preserve">ОТФИЛЬТРОВАНО:</x:String>
<x:String x:Key="Text.Repository.LocalBranches" xml:space="preserve">ЛОКАЛЬНЫЕ ВЕТКИ</x:String>
<x:String x:Key="Text.Repository.NavigateToCurrentHead" xml:space="preserve">Навигация по заголовку</x:String>
<x:String x:Key="Text.Repository.FirstParentFilterToggle" xml:space="preserve">Включить опцию --first-parent</x:String>

View file

@ -37,17 +37,17 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.4" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.4" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.1.4" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Avalonia" Version="11.2.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.1" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.1" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.1.0" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Avalonia" Version="2.0.0-rc3.3" />
<PackageReference Include="TextMateSharp" Version="1.0.63" />
<PackageReference Include="TextMateSharp.Grammars" Version="1.0.63" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Avalonia" Version="2.0.0-rc4.5" />
<PackageReference Include="TextMateSharp" Version="1.0.64" />
<PackageReference Include="TextMateSharp.Grammars" Version="1.0.64" />
</ItemGroup>
<ItemGroup>

View file

@ -64,8 +64,8 @@ namespace SourceGit.ViewModels
CallUIThread(() =>
{
var b = _repo.Branches.Find(x => x.IsLocal && x.Name == Branch);
if (b != null)
_repo.UpdateHistoriesFilterAfterCheckout(b);
if (b != null && _repo.HistoriesFilterMode == Models.FilterMode.Included)
_repo.Settings.UpdateHistoriesFilter(b.FullName, Models.FilterType.LocalBranch, Models.FilterMode.Included);
_repo.MarkBranchesDirtyManually();
_repo.SetWatcherEnabled(true);

View file

@ -125,14 +125,8 @@ namespace SourceGit.ViewModels
CallUIThread(() =>
{
if (CheckoutAfterCreated)
{
_repo.UpdateHistoriesFilterAfterCheckout(new Models.Branch()
{
FullName = $"refs/heads/{_name}",
Upstream = BasedOn is Models.Branch { IsLocal: false } remoteBranch ? remoteBranch.FullName : string.Empty,
});
}
if (CheckoutAfterCreated && _repo.HistoriesFilterMode == Models.FilterMode.Included)
_repo.Settings.UpdateHistoriesFilter($"refs/heads/{_name}", Models.FilterType.LocalBranch, Models.FilterMode.Included);
_repo.MarkBranchesDirtyManually();
_repo.SetWatcherEnabled(true);

View file

@ -46,6 +46,12 @@ namespace SourceGit.ViewModels
get => _settings;
}
public Models.FilterMode HistoriesFilterMode
{
get => _historiesFilterMode;
private set => SetProperty(ref _historiesFilterMode, value);
}
public bool HasAllowedSignersFile
{
get => _hasAllowedSignersFile;
@ -383,6 +389,11 @@ namespace SourceGit.ViewModels
App.RaiseException(string.Empty, $"Failed to start watcher for repository: '{_fullpath}'. You may need to press 'F5' to refresh repository manually!\n\nReason: {ex.Message}");
}
if (_settings.HistoriesFilters.Count > 0)
_historiesFilterMode = _settings.HistoriesFilters[0].Mode;
else
_historiesFilterMode = Models.FilterMode.None;
_histories = new Histories(this);
_workingCopy = new WorkingCopy(this);
_stashesPage = new StashesPage(this);
@ -407,6 +418,7 @@ namespace SourceGit.ViewModels
// Ignore
}
_settings = null;
_historiesFilterMode = Models.FilterMode.None;
_autoFetchTimer.Dispose();
_autoFetchTimer = null;
@ -670,49 +682,92 @@ namespace SourceGit.ViewModels
public void ClearHistoriesFilter()
{
_settings.HistoriesFilters.Clear();
HistoriesFilterMode = Models.FilterMode.None;
ResetBranchTreeFilterMode(LocalBranchTrees);
ResetBranchTreeFilterMode(RemoteBranchTrees);
ResetTagFilterMode();
Task.Run(RefreshCommits);
}
public void MarkHistoriesFilterDirty()
public void SetTagFilterMode(Models.Tag tag, Models.FilterMode mode)
{
UpdateBranchTreeFilterMode(LocalBranchTrees, true);
UpdateBranchTreeFilterMode(RemoteBranchTrees, false);
UpdateTagFilterMode();
Task.Run(RefreshCommits);
var changed = _settings.UpdateHistoriesFilter(tag.Name, Models.FilterType.Tag, mode);
if (changed)
{
if (mode != Models.FilterMode.None || _settings.HistoriesFilters.Count == 0)
HistoriesFilterMode = mode;
RefreshHistoriesFilters();
}
}
public void UpdateHistoriesFilterAfterCheckout(Models.Branch local)
public void SetBranchFilterMode(BranchTreeNode node, Models.FilterMode mode)
{
var hasIncludedBranch = false;
foreach (var filter in _settings.HistoriesFilters)
var isLocal = node.Path.StartsWith("refs/heads/", StringComparison.Ordinal);
var tree = isLocal ? _localBranchTrees : _remoteBranchTrees;
if (node.Backend is Models.Branch branch)
{
if (filter.Type == Models.FilterType.LocalBranch)
{
if (filter.Pattern.Equals(local.FullName, StringComparison.Ordinal))
return;
var type = isLocal ? Models.FilterType.LocalBranch : Models.FilterType.RemoteBranch;
var changed = _settings.UpdateHistoriesFilter(node.Path, type, mode);
if (!changed)
return;
hasIncludedBranch |= filter.Mode == Models.FilterMode.Included;
}
else if (filter.Type == Models.FilterType.LocalBranchFolder)
if (isLocal && !string.IsNullOrEmpty(branch.Upstream) && mode != Models.FilterMode.Excluded)
{
if (local.FullName.StartsWith(filter.Pattern, StringComparison.Ordinal))
return;
var upstream = branch.Upstream;
var canUpdateUpstream = true;
foreach (var filter in _settings.HistoriesFilters)
{
bool matched = false;
if (filter.Type == Models.FilterType.RemoteBranch)
matched = filter.Pattern.Equals(upstream, StringComparison.Ordinal);
else if (filter.Type == Models.FilterType.RemoteBranchFolder)
matched = upstream.StartsWith(filter.Pattern, StringComparison.Ordinal);
hasIncludedBranch |= filter.Mode == Models.FilterMode.Included;
}
else if (filter.Type == Models.FilterType.RemoteBranch || filter.Type == Models.FilterType.RemoteBranchFolder)
{
hasIncludedBranch |= filter.Mode == Models.FilterMode.Included;
if (matched && filter.Mode == Models.FilterMode.Excluded)
{
canUpdateUpstream = false;
break;
}
}
if (canUpdateUpstream)
_settings.UpdateHistoriesFilter(upstream, Models.FilterType.RemoteBranch, mode);
}
}
else
{
var type = isLocal ? Models.FilterType.LocalBranchFolder : Models.FilterType.RemoteBranchFolder;
var changed = _settings.UpdateHistoriesFilter(node.Path, type, mode);
if (!changed)
return;
if (!hasIncludedBranch)
return;
_settings.RemoveChildrenBranchFilters(node.Path);
}
_settings.UpdateHistoriesFilter(local.FullName, Models.FilterType.LocalBranch, Models.FilterMode.Included);
var parentType = isLocal ? Models.FilterType.LocalBranchFolder : Models.FilterType.RemoteBranchFolder;
var cur = node;
do
{
var lastSepIdx = cur.Path.LastIndexOf('/');
if (lastSepIdx <= 0)
break;
var parentPath = cur.Path.Substring(0, lastSepIdx);
var parent = FindBranchNode(tree, parentPath);
if (parent == null)
break;
_settings.UpdateHistoriesFilter(parent.Path, parentType, Models.FilterMode.None);
cur = parent;
} while (true);
if (mode != Models.FilterMode.None || _settings.HistoriesFilters.Count == 0)
HistoriesFilterMode = mode;
RefreshHistoriesFilters();
}
public void StashAll(bool autoStart)
@ -2023,6 +2078,14 @@ namespace SourceGit.ViewModels
return visible;
}
private void RefreshHistoriesFilters()
{
UpdateBranchTreeFilterMode(LocalBranchTrees, true);
UpdateBranchTreeFilterMode(RemoteBranchTrees, false);
UpdateTagFilterMode();
Task.Run(RefreshCommits);
}
private void UpdateBranchTreeFilterMode(List<BranchTreeNode> nodes, bool isLocal)
{
foreach (var node in nodes)
@ -2061,6 +2124,24 @@ namespace SourceGit.ViewModels
tag.FilterMode = Models.FilterMode.None;
}
private BranchTreeNode FindBranchNode(List<BranchTreeNode> nodes, string path)
{
foreach (var node in nodes)
{
if (node.Path.Equals(path, StringComparison.Ordinal))
return node;
if (path.StartsWith(node.Path, StringComparison.Ordinal))
{
var founded = FindBranchNode(node.Children, path);
if (founded != null)
return founded;
}
}
return null;
}
private void UpdateCurrentRevisionFilesForSearchSuggestion()
{
_revisionFiles.Clear();
@ -2124,6 +2205,7 @@ namespace SourceGit.ViewModels
private string _fullpath = string.Empty;
private string _gitDir = string.Empty;
private Models.RepositorySettings _settings = null;
private Models.FilterMode _historiesFilterMode = Models.FilterMode.None;
private bool _hasAllowedSignersFile = false;
private Models.Watcher _watcher = null;

View file

@ -130,7 +130,7 @@ namespace SourceGit.Views
if (c != null)
{
ToolTip.SetTip(ctl, c);
ToolTip.SetIsOpen(ctl, true);
ToolTip.SetIsOpen(ctl, ctl.IsPointerOver);
}
}
}

View file

@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
@ -82,7 +79,7 @@ namespace SourceGit.Views
unset.Header = App.Text("Repository.FilterCommits.Default");
unset.Click += (_, ev) =>
{
UpdateTagFilterMode(repo, tag, Models.FilterMode.None);
repo.SetTagFilterMode(tag, Models.FilterMode.None);
ev.Handled = true;
};
@ -96,7 +93,7 @@ namespace SourceGit.Views
include.IsEnabled = mode != Models.FilterMode.Included;
include.Click += (_, ev) =>
{
UpdateTagFilterMode(repo, tag, Models.FilterMode.Included);
repo.SetTagFilterMode(tag, Models.FilterMode.Included);
ev.Handled = true;
};
@ -106,7 +103,7 @@ namespace SourceGit.Views
exclude.IsEnabled = mode != Models.FilterMode.Excluded;
exclude.Click += (_, ev) =>
{
UpdateTagFilterMode(repo, tag, Models.FilterMode.Excluded);
repo.SetTagFilterMode(tag, Models.FilterMode.Excluded);
ev.Handled = true;
};
@ -123,7 +120,7 @@ namespace SourceGit.Views
unset.Header = App.Text("Repository.FilterCommits.Default");
unset.Click += (_, ev) =>
{
UpdateBranchFilterMode(repo, node, Models.FilterMode.None);
repo.SetBranchFilterMode(node, Models.FilterMode.None);
ev.Handled = true;
};
@ -137,7 +134,7 @@ namespace SourceGit.Views
include.IsEnabled = mode != Models.FilterMode.Included;
include.Click += (_, ev) =>
{
UpdateBranchFilterMode(repo, node, Models.FilterMode.Included);
repo.SetBranchFilterMode(node, Models.FilterMode.Included);
ev.Handled = true;
};
@ -147,7 +144,7 @@ namespace SourceGit.Views
exclude.IsEnabled = mode != Models.FilterMode.Excluded;
exclude.Click += (_, ev) =>
{
UpdateBranchFilterMode(repo, node, Models.FilterMode.Excluded);
repo.SetBranchFilterMode(node, Models.FilterMode.Excluded);
ev.Handled = true;
};
@ -164,113 +161,6 @@ namespace SourceGit.Views
menu.Open(button);
e.Handled = true;
}
private void UpdateTagFilterMode(ViewModels.Repository repo, Models.Tag tag, Models.FilterMode mode)
{
var changed = repo.Settings.UpdateHistoriesFilter(tag.Name, Models.FilterType.Tag, mode);
repo.MarkHistoriesFilterDirty();
}
private void UpdateBranchFilterMode(ViewModels.Repository repo, ViewModels.BranchTreeNode node, Models.FilterMode mode)
{
var isLocal = node.Path.StartsWith("refs/heads/", StringComparison.Ordinal);
var type = isLocal ? Models.FilterType.LocalBranch : Models.FilterType.RemoteBranch;
var tree = isLocal ? repo.LocalBranchTrees : repo.RemoteBranchTrees;
if (node.Backend is Models.Branch branch)
{
var changed = repo.Settings.UpdateHistoriesFilter(node.Path, type, mode);
if (!changed)
return;
// Try to update its upstream.
if (isLocal && !string.IsNullOrEmpty(branch.Upstream) && mode != Models.FilterMode.Excluded)
{
var upstream = branch.Upstream;
var canUpdateUpstream = true;
foreach (var filter in repo.Settings.HistoriesFilters)
{
bool matched = false;
if (filter.Type == Models.FilterType.RemoteBranch)
matched = filter.Pattern.Equals(upstream, StringComparison.Ordinal);
else if (filter.Type == Models.FilterType.RemoteBranchFolder)
matched = upstream.StartsWith(filter.Pattern, StringComparison.Ordinal);
if (matched && filter.Mode == Models.FilterMode.Excluded)
{
canUpdateUpstream = false;
break;
}
}
if (canUpdateUpstream)
repo.Settings.UpdateHistoriesFilter(upstream, Models.FilterType.RemoteBranch, mode);
}
}
else
{
var changed = repo.Settings.UpdateHistoriesFilter(node.Path, isLocal ? Models.FilterType.LocalBranchFolder : Models.FilterType.RemoteBranchFolder, mode);
if (!changed)
return;
ResetChildrenBranchNodeFilterMode(repo, node, isLocal);
}
var parentType = isLocal ? Models.FilterType.LocalBranchFolder : Models.FilterType.RemoteBranchFolder;
var cur = node;
do
{
var lastSepIdx = cur.Path.LastIndexOf('/');
if (lastSepIdx <= 0)
break;
var parentPath = cur.Path.Substring(0, lastSepIdx);
var parent = FindBranchNode(tree, parentPath);
if (parent == null)
break;
repo.Settings.UpdateHistoriesFilter(parent.Path, parentType, Models.FilterMode.None);
cur = parent;
} while (true);
repo.MarkHistoriesFilterDirty();
}
private void ResetChildrenBranchNodeFilterMode(ViewModels.Repository repo, ViewModels.BranchTreeNode node, bool isLocal)
{
foreach (var child in node.Children)
{
if (child.IsBranch)
{
var type = isLocal ? Models.FilterType.LocalBranch : Models.FilterType.RemoteBranch;
repo.Settings.UpdateHistoriesFilter(child.Path, type, Models.FilterMode.None);
}
else
{
var type = isLocal ? Models.FilterType.LocalBranchFolder : Models.FilterType.RemoteBranchFolder;
repo.Settings.UpdateHistoriesFilter(child.Path, type, Models.FilterMode.None);
ResetChildrenBranchNodeFilterMode(repo, child, isLocal);
}
}
}
private ViewModels.BranchTreeNode FindBranchNode(List<ViewModels.BranchTreeNode> nodes, string path)
{
foreach (var node in nodes)
{
if (node.Path.Equals(path, StringComparison.Ordinal))
return node;
if (path.StartsWith(node.Path, StringComparison.Ordinal))
{
var founded = FindBranchNode(node.Children, path);
if (founded != null)
return founded;
}
}
return null;
}
}
}

View file

@ -730,9 +730,12 @@ namespace SourceGit.Views
private void OnCommitListDoubleTapped(object sender, TappedEventArgs e)
{
if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems: { Count: 1 } selected })
if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems: { Count: 1 } })
{
histories.DoubleTapped(selected[0] as Models.Commit);
var source = e.Source as Control;
var item = source.FindAncestorOfType<ListBoxItem>();
if (item is { DataContext: Models.Commit commit })
histories.DoubleTapped(commit);
}
e.Handled = true;
}

View file

@ -575,12 +575,19 @@
<Grid Height="28" ColumnDefinitions="Auto,*,Auto">
<Path Grid.Column="0"
x:Name="HistoriesFilterModeIcon"
Margin="8,0,0,0"
Width="14" Height="14"
Fill="{DynamicResource Brush.FG2}"/>
Width="12" Height="12"
Data="{StaticResource Icons.Filter}"
Fill="{DynamicResource Brush.FG2}"
IsVisible="{Binding HistoriesFilterMode, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:FilterMode.Included}}"/>
<Path Grid.Column="0"
Margin="8,0,0,0"
Width="12" Height="12"
Data="{StaticResource Icons.EyeClose}"
Fill="{DynamicResource Brush.FG2}"
IsVisible="{Binding HistoriesFilterMode, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:FilterMode.Excluded}}"/>
<ItemsControl Grid.Column="1" Margin="8,0,0,0" ItemsSource="{Binding Settings.HistoriesFilters}" LayoutUpdated="OnHistoriesFiltersLayoutUpdated">
<ItemsControl Grid.Column="1" Margin="8,0,0,0" ItemsSource="{Binding Settings.HistoriesFilters}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
@ -604,8 +611,8 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button Grid.Column="2" Classes="icon_button" Command="{Binding ClearHistoriesFilter}">
<TextBlock Margin="16,0,8,0" Text="{DynamicResource Text.Repository.ClearAllCommitsFilter}" Foreground="{DynamicResource Brush.Accent}"/>
<Button Grid.Column="2" Classes="icon_button" Command="{Binding ClearHistoriesFilter}" ToolTip.Tip="{DynamicResource Text.Repository.ClearAllCommitsFilter}">
<Path Width="14" Height="14" Margin="16,0,8,0" Data="{StaticResource Icons.RemoveAll}"/>
</Button>
</Grid>
</Border>

View file

@ -395,40 +395,5 @@ namespace SourceGit.Views
}
e.Handled = true;
}
private void OnHistoriesFiltersLayoutUpdated(object sender, EventArgs e)
{
var repo = DataContext as ViewModels.Repository;
if (repo == null)
return;
var filters = repo.Settings.HistoriesFilters;
if (filters.Count == 0)
return;
var mode = filters[0].Mode;
if (mode == _lastFilterMode)
return;
_lastFilterMode = mode;
var icon = null as StreamGeometry;
switch (mode)
{
case Models.FilterMode.Included:
icon = this.FindResource("Icons.Filter") as StreamGeometry;
break;
case Models.FilterMode.Excluded:
icon = this.FindResource("Icons.EyeClose") as StreamGeometry;
break;
default:
break;
}
if (icon != null)
HistoriesFilterModeIcon.Data = icon;
}
private Models.FilterMode _lastFilterMode = Models.FilterMode.None;
}
}