From 12b12048092ee966f8db3a8566814b35fbadfd99 Mon Sep 17 00:00:00 2001 From: AquariusStar <48148723+AquariusStar@users.noreply.github.com> Date: Mon, 14 Apr 2025 04:47:23 +0300 Subject: [PATCH 1/9] update russian localization (#1181) --- src/Resources/Locales/ru_RU.axaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index b26532ae..ee04f4d1 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -157,6 +157,7 @@ Автозагрузка изменений Минут(а/ы) Внешний репозиторий по умолчанию + Предпочтительный режим слияния ОТСЛЕЖИВАНИЕ ПРОБЛЕМ Добавить пример правила Azure DevOps Добавить пример правила для тем в Gitea @@ -181,6 +182,10 @@ Цвет Имя Восстанавливать вкладки при запуске + ПРОДОЛЖИТЬ + Обнаружена пустая ревизия! Вы хотите продолжить (--allow-empty)? + Подготовить все и зафиксировать ревизию + Обнаружена пустая ревизия! Вы хотите продолжить (--allow-empty) или отложить все, затем зафиксировать ревизию? Общепринятый помощник по ревизии Кардинальные изменения: Закрытая тема: @@ -725,8 +730,13 @@ Запустить событие щелчка Зафиксировать (Редактировать) Подготовить все изменения и зафиксировать + Вы подготовили {0} файл(ов), но отображается только {1} файл(ов) ({2} файл(ов) отфильтровано). Вы хотите продолжить? ОБНАРУЖЕНЫ КОНФЛИКТЫ + ОТКРЫТЬ ВНЕШНИЙ ИНСТРУМЕНТ СЛИЯНИЯ + ОТКРЫТЬ ВСЕ КОНФЛИКТЫ ВО ВНЕШНЕМ ИНСТРУМЕНТЕ СЛИЯНИЯ КОНФЛИКТЫ ФАЙЛОВ РАЗРЕШЕНЫ + ИСПОЛЬЗОВАТЬ МОИ + ИСПОЛЬЗОВАТЬ ИХ ВКЛЮЧИТЬ НЕОТСЛЕЖИВАЕМЫЕ ФАЙЛЫ НЕТ ПОСЛЕДНИХ ВХОДНЫХ СООБЩЕНИЙ НЕТ ШАБЛОНОВ РЕВИЗИИ From 241f92a29020eb3aad0cf50674dcc5564640e755 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 14 Apr 2025 01:47:39 +0000 Subject: [PATCH 2/9] doc: Update translation status and missing keys --- TRANSLATION.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/TRANSLATION.md b/TRANSLATION.md index ccf003c7..a2991c6e 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -195,23 +195,7 @@ This document shows the translation status of each locale file in the repository -### ![ru__RU](https://img.shields.io/badge/ru__RU-98.67%25-yellow) - -
-Missing keys in ru_RU.axaml - -- Text.Configure.Git.PreferredMergeMode -- Text.ConfirmEmptyCommit.Continue -- Text.ConfirmEmptyCommit.NoLocalChanges -- Text.ConfirmEmptyCommit.StageAllThenCommit -- Text.ConfirmEmptyCommit.WithLocalChanges -- Text.WorkingCopy.ConfirmCommitWithFilter -- Text.WorkingCopy.Conflicts.OpenExternalMergeTool -- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts -- Text.WorkingCopy.Conflicts.UseMine -- Text.WorkingCopy.Conflicts.UseTheirs - -
+### ![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen) ### ![ta__IN](https://img.shields.io/badge/ta__IN-98.67%25-yellow) From 48835ca043787f477a4ed014381fa564f3354d1c Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 14 Apr 2025 09:53:59 +0800 Subject: [PATCH 3/9] project: upgrade `AvaloniaUI` to `11.2.7` Signed-off-by: leo --- src/SourceGit.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index 852c9e34..293c8630 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -41,11 +41,11 @@ - - - - - + + + + + From 69d8d963eafa84bcb38612e73ff8e37ee3c6bd9c Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 14 Apr 2025 09:55:49 +0800 Subject: [PATCH 4/9] version: Release 2025.13 Signed-off-by: leo --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8283ecf3..c29bf2a5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2025.12 \ No newline at end of file +2025.13 \ No newline at end of file From 245de9b4583f499c3e1b6e8c176e9f9fc3d48932 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 14 Apr 2025 10:40:24 +0800 Subject: [PATCH 5/9] fix: tooltip did not hide after pointer move out (#1178) Signed-off-by: leo --- src/Views/Blame.axaml | 9 +++++++- src/Views/Blame.axaml.cs | 3 +-- src/Views/CommitBaseInfo.axaml | 14 +++++++++++++ src/Views/CommitBaseInfo.axaml.cs | 5 ----- src/Views/CommitMessagePresenter.cs | 32 ++++++++++++++++------------- src/Views/CommitSubjectPresenter.cs | 1 - 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/Views/Blame.axaml b/src/Views/Blame.axaml index eaad985a..7a3d7ddf 100644 --- a/src/Views/Blame.axaml +++ b/src/Views/Blame.axaml @@ -59,7 +59,14 @@ FontFamily="{DynamicResource Fonts.Monospace}" FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}" TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}" - BlameData="{Binding Data}"/> + BlameData="{Binding Data}"> + + + + + + + + + + + + + + @@ -152,6 +159,13 @@ PointerEntered="OnSHAPointerEntered" PointerPressed="OnSHAPressed" ToolTip.ShowDelay="0"> + + + + + + + diff --git a/src/Views/CommitBaseInfo.axaml.cs b/src/Views/CommitBaseInfo.axaml.cs index 8767db9f..ac9b53cc 100644 --- a/src/Views/CommitBaseInfo.axaml.cs +++ b/src/Views/CommitBaseInfo.axaml.cs @@ -133,12 +133,7 @@ namespace SourceGit.Views Dispatcher.UIThread.Invoke(() => { if (ctl.IsEffectivelyVisible && ctl.DataContext is string newSHA && newSHA == sha) - { ToolTip.SetTip(ctl, c); - - if (ctl.IsPointerOver) - ToolTip.SetIsOpen(ctl, true); - } }); }); } diff --git a/src/Views/CommitMessagePresenter.cs b/src/Views/CommitMessagePresenter.cs index 002beda1..6f838509 100644 --- a/src/Views/CommitMessagePresenter.cs +++ b/src/Views/CommitMessagePresenter.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Documents; +using Avalonia.Data; +using Avalonia.Data.Converters; using Avalonia.Input; using Avalonia.Threading; using Avalonia.VisualTree; @@ -24,6 +26,21 @@ namespace SourceGit.Views protected override Type StyleKeyOverride => typeof(SelectableTextBlock); + public CommitMessagePresenter() + { + var bindings = new MultiBinding() + { + Converter = BoolConverters.And, + Bindings = new[] + { + new Binding() { Path = "IsPointerOver", Source = this }, + new Binding() { Path = "(ToolTip.Tip)", Source = this, TypeResolver = (_, name) => name == "ToolTip" ? typeof(ToolTip) : null, Converter = ObjectConverters.IsNotNull }, + } + }; + + Bind(ToolTip.IsOpenProperty, bindings); + } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change); @@ -107,14 +124,9 @@ namespace SourceGit.Views _lastHover = link; if (!link.IsCommitSHA) - { ToolTip.SetTip(this, link.Link); - ToolTip.SetIsOpen(this, true); - } else - { ProcessHoverCommitLink(link); - } return; } @@ -264,12 +276,7 @@ namespace SourceGit.Views // If we have already queried this SHA, just use it. if (_inlineCommits.TryGetValue(sha, out var exist)) { - if (exist != null) - { - ToolTip.SetTip(this, exist); - ToolTip.SetIsOpen(this, true); - } - + ToolTip.SetTip(this, exist); return; } @@ -294,10 +301,7 @@ namespace SourceGit.Views // Make sure user still hovers the target SHA. if (_lastHover == link && c != null) - { ToolTip.SetTip(this, c); - ToolTip.SetIsOpen(this, true); - } } }); }); diff --git a/src/Views/CommitSubjectPresenter.cs b/src/Views/CommitSubjectPresenter.cs index 32f6838d..83d79fe4 100644 --- a/src/Views/CommitSubjectPresenter.cs +++ b/src/Views/CommitSubjectPresenter.cs @@ -144,7 +144,6 @@ namespace SourceGit.Views _lastHover = match; SetCurrentValue(CursorProperty, Cursor.Parse("Hand")); ToolTip.SetTip(this, match.Link); - ToolTip.SetIsOpen(this, true); e.Handled = true; return; } From 17cf402c7819eb04594730c9ca6673413c3a72f5 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 14 Apr 2025 10:42:34 +0800 Subject: [PATCH 6/9] enhance: navigate to upstream head after fetch, pull, and merge (#1180) --- src/Commands/QueryBranches.cs | 4 ++-- src/Models/Branch.cs | 2 +- src/ViewModels/BranchTreeNode.cs | 2 +- src/ViewModels/FastForwardWithoutCheckout.cs | 6 +++++- src/ViewModels/Fetch.cs | 9 +++++---- src/ViewModels/FetchInto.cs | 6 +++++- src/ViewModels/Merge.cs | 17 ++++++++++++++++- src/ViewModels/Pull.cs | 6 +++++- src/ViewModels/Repository.cs | 20 ++++++++++++++++++++ 9 files changed, 60 insertions(+), 12 deletions(-) diff --git a/src/Commands/QueryBranches.cs b/src/Commands/QueryBranches.cs index 8dbc4055..39b77189 100644 --- a/src/Commands/QueryBranches.cs +++ b/src/Commands/QueryBranches.cs @@ -40,7 +40,7 @@ namespace SourceGit.Commands foreach (var b in branches) { if (b.IsLocal && !string.IsNullOrEmpty(b.Upstream)) - b.IsUpsteamGone = !remoteBranches.Contains(b.Upstream); + b.IsUpstreamGone = !remoteBranches.Contains(b.Upstream); } return branches; @@ -86,7 +86,7 @@ namespace SourceGit.Commands branch.Head = parts[1]; branch.IsCurrent = parts[2] == "*"; branch.Upstream = parts[3]; - branch.IsUpsteamGone = false; + branch.IsUpstreamGone = false; if (branch.IsLocal && !string.IsNullOrEmpty(parts[4]) && !parts[4].Equals("=", StringComparison.Ordinal)) branch.TrackStatus = new QueryTrackStatus(WorkingDirectory, branch.Name, branch.Upstream).Result(); diff --git a/src/Models/Branch.cs b/src/Models/Branch.cs index 2d0ae5b2..d0ac1990 100644 --- a/src/Models/Branch.cs +++ b/src/Models/Branch.cs @@ -34,7 +34,7 @@ namespace SourceGit.Models public string Upstream { get; set; } public BranchTrackStatus TrackStatus { get; set; } public string Remote { get; set; } - public bool IsUpsteamGone { get; set; } + public bool IsUpstreamGone { get; set; } public string FriendlyName => IsLocal ? Name : $"{Remote}/{Name}"; } diff --git a/src/ViewModels/BranchTreeNode.cs b/src/ViewModels/BranchTreeNode.cs index 6c1d2e04..0148844a 100644 --- a/src/ViewModels/BranchTreeNode.cs +++ b/src/ViewModels/BranchTreeNode.cs @@ -44,7 +44,7 @@ namespace SourceGit.ViewModels public bool ShowUpstreamGoneTip { - get => Backend is Models.Branch { IsUpsteamGone: true }; + get => Backend is Models.Branch { IsUpstreamGone: true }; } public string Tooltip diff --git a/src/ViewModels/FastForwardWithoutCheckout.cs b/src/ViewModels/FastForwardWithoutCheckout.cs index df4b4d73..974730a7 100644 --- a/src/ViewModels/FastForwardWithoutCheckout.cs +++ b/src/ViewModels/FastForwardWithoutCheckout.cs @@ -32,7 +32,11 @@ namespace SourceGit.ViewModels return Task.Run(() => { new Commands.UpdateRef(_repo.FullPath, Local.FullName, To.FullName, SetProgressDescription).Exec(); - CallUIThread(() => _repo.SetWatcherEnabled(true)); + CallUIThread(() => + { + _repo.NavigateToCommit(To.Head); + _repo.SetWatcherEnabled(true); + }); return true; }); } diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index 1094012e..cc38aa70 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -34,14 +34,14 @@ namespace SourceGit.ViewModels set => _repo.Settings.EnableForceOnFetch = value; } - public Fetch(Repository repo, Models.Remote preferedRemote = null) + public Fetch(Repository repo, Models.Remote preferredRemote = null) { _repo = repo; - _fetchAllRemotes = preferedRemote == null; + _fetchAllRemotes = preferredRemote == null; - if (preferedRemote != null) + if (preferredRemote != null) { - SelectedRemote = preferedRemote; + SelectedRemote = preferredRemote; } else if (!string.IsNullOrEmpty(_repo.Settings.DefaultRemote)) { @@ -83,6 +83,7 @@ namespace SourceGit.ViewModels CallUIThread(() => { + _repo.SetNeedNavigateToUpstreamHead(); _repo.MarkFetched(); _repo.SetWatcherEnabled(true); }); diff --git a/src/ViewModels/FetchInto.cs b/src/ViewModels/FetchInto.cs index a52b1cd6..8143ac9c 100644 --- a/src/ViewModels/FetchInto.cs +++ b/src/ViewModels/FetchInto.cs @@ -32,7 +32,11 @@ namespace SourceGit.ViewModels return Task.Run(() => { new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec(); - CallUIThread(() => _repo.SetWatcherEnabled(true)); + CallUIThread(() => + { + _repo.SetNeedNavigateToUpstreamHead(); + _repo.SetWatcherEnabled(true); + }); return true; }); } diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index faadaf57..7130bb30 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -62,7 +62,22 @@ namespace SourceGit.ViewModels return Task.Run(() => { new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec(); - CallUIThread(() => _repo.SetWatcherEnabled(true)); + CallUIThread(() => + { + switch (Source) + { + case Models.Branch branch: + _repo.NavigateToCommit(branch.Head); + break; + case Models.Commit commit: + _repo.NavigateToCommit(commit.SHA); + break; + case Models.Tag tag: + _repo.NavigateToCommit(tag.SHA); + break; + } + _repo.SetWatcherEnabled(true); + }); return true; }); } diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 62d68834..f40b0916 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -192,7 +192,11 @@ namespace SourceGit.ViewModels rs = new Commands.Stash(_repo.FullPath).Pop("stash@{0}"); } - CallUIThread(() => _repo.SetWatcherEnabled(true)); + CallUIThread(() => + { + _repo.SetNeedNavigateToUpstreamHead(); + _repo.SetWatcherEnabled(true); + }); return rs; }); } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 6b1e439e..617105d9 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -717,6 +717,11 @@ namespace SourceGit.ViewModels _watcher?.SetEnabled(enabled); } + public void SetNeedNavigateToUpstreamHead() + { + _needNavigateToUpstreamHead = true; + } + public void MarkBranchesDirtyManually() { if (_watcher == null) @@ -773,6 +778,15 @@ namespace SourceGit.ViewModels NavigateToCommit(_currentBranch.Head); } + public void NavigateToCurrentUpstreamHead() + { + if (_currentBranch == null || string.IsNullOrEmpty(_currentBranch.Upstream)) + return; + var branch = _branches.Find(x => x.FullName == _currentBranch.Upstream); + if (branch != null) + NavigateToCommit(branch.Head); + } + public void ClearHistoriesFilter() { _settings.HistoriesFilters.Clear(); @@ -991,6 +1005,11 @@ namespace SourceGit.ViewModels _histories.IsLoading = false; _histories.Commits = commits; _histories.Graph = graph; + if (_needNavigateToUpstreamHead) + { + NavigateToCurrentUpstreamHead(); + _needNavigateToUpstreamHead = false; + } } }); } @@ -2588,5 +2607,6 @@ namespace SourceGit.ViewModels private bool _isAutoFetching = false; private Timer _autoFetchTimer = null; private DateTime _lastFetchTime = DateTime.MinValue; + private bool _needNavigateToUpstreamHead = false; } } From 0cb2ca78fe7ab2e10aee308b6ac7378d864574c2 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 14 Apr 2025 11:35:50 +0800 Subject: [PATCH 7/9] code_review: PR #1180 - replace `SetNeedNavigateToUpstreamHead` with `NavigateToBranchDelayed` - navigate to current HEAD instead of original source HEAD after merge Signed-off-by: leo --- src/ViewModels/Fetch.cs | 2 +- src/ViewModels/FetchInto.cs | 2 +- src/ViewModels/Merge.cs | 13 +------------ src/ViewModels/Pull.cs | 2 +- src/ViewModels/Repository.cs | 26 +++++++++++--------------- 5 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index cc38aa70..35e34bb3 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -83,7 +83,7 @@ namespace SourceGit.ViewModels CallUIThread(() => { - _repo.SetNeedNavigateToUpstreamHead(); + _repo.NavigateToBranchDelayed(_repo.CurrentBranch?.Upstream); _repo.MarkFetched(); _repo.SetWatcherEnabled(true); }); diff --git a/src/ViewModels/FetchInto.cs b/src/ViewModels/FetchInto.cs index 8143ac9c..878b0416 100644 --- a/src/ViewModels/FetchInto.cs +++ b/src/ViewModels/FetchInto.cs @@ -34,7 +34,7 @@ namespace SourceGit.ViewModels new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec(); CallUIThread(() => { - _repo.SetNeedNavigateToUpstreamHead(); + _repo.NavigateToBranchDelayed(Upstream.FullName); _repo.SetWatcherEnabled(true); }); return true; diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index 7130bb30..8b2ad537 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -64,18 +64,7 @@ namespace SourceGit.ViewModels new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec(); CallUIThread(() => { - switch (Source) - { - case Models.Branch branch: - _repo.NavigateToCommit(branch.Head); - break; - case Models.Commit commit: - _repo.NavigateToCommit(commit.SHA); - break; - case Models.Tag tag: - _repo.NavigateToCommit(tag.SHA); - break; - } + _repo.NavigateToBranchDelayed(_repo.CurrentBranch?.FullName); _repo.SetWatcherEnabled(true); }); return true; diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index f40b0916..465a393a 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -194,7 +194,7 @@ namespace SourceGit.ViewModels CallUIThread(() => { - _repo.SetNeedNavigateToUpstreamHead(); + _repo.NavigateToBranchDelayed(_repo.CurrentBranch?.FullName); _repo.SetWatcherEnabled(true); }); return rs; diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 617105d9..9b720c7b 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -717,11 +717,6 @@ namespace SourceGit.ViewModels _watcher?.SetEnabled(enabled); } - public void SetNeedNavigateToUpstreamHead() - { - _needNavigateToUpstreamHead = true; - } - public void MarkBranchesDirtyManually() { if (_watcher == null) @@ -778,13 +773,9 @@ namespace SourceGit.ViewModels NavigateToCommit(_currentBranch.Head); } - public void NavigateToCurrentUpstreamHead() + public void NavigateToBranchDelayed(string branch) { - if (_currentBranch == null || string.IsNullOrEmpty(_currentBranch.Upstream)) - return; - var branch = _branches.Find(x => x.FullName == _currentBranch.Upstream); - if (branch != null) - NavigateToCommit(branch.Head); + _navigateToBranchDelayed = branch; } public void ClearHistoriesFilter() @@ -1005,12 +996,16 @@ namespace SourceGit.ViewModels _histories.IsLoading = false; _histories.Commits = commits; _histories.Graph = graph; - if (_needNavigateToUpstreamHead) + + if (!string.IsNullOrEmpty(_navigateToBranchDelayed)) { - NavigateToCurrentUpstreamHead(); - _needNavigateToUpstreamHead = false; + var branch = _branches.Find(x => x.FullName == _navigateToBranchDelayed); + if (branch != null) + NavigateToCommit(branch.Head); } } + + _navigateToBranchDelayed = string.Empty; }); } @@ -2607,6 +2602,7 @@ namespace SourceGit.ViewModels private bool _isAutoFetching = false; private Timer _autoFetchTimer = null; private DateTime _lastFetchTime = DateTime.MinValue; - private bool _needNavigateToUpstreamHead = false; + + private string _navigateToBranchDelayed = string.Empty; } } From e7f0217a7b66704b7a446d0572f2f89e39161e24 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 14 Apr 2025 11:51:40 +0800 Subject: [PATCH 8/9] refactor: move binding for `ToolTip.IsOpen` from code to axaml Signed-off-by: leo --- src/Views/CommitBaseInfo.axaml | 7 +++++++ src/Views/CommitMessagePresenter.cs | 17 ----------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index 43b28288..bdf5f226 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -203,6 +203,13 @@ FullMessage="{Binding #ThisControl.FullMessage}" HorizontalAlignment="Stretch" TextWrapping="Wrap"> + + + + + + + diff --git a/src/Views/CommitMessagePresenter.cs b/src/Views/CommitMessagePresenter.cs index 6f838509..c71c9687 100644 --- a/src/Views/CommitMessagePresenter.cs +++ b/src/Views/CommitMessagePresenter.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Documents; -using Avalonia.Data; -using Avalonia.Data.Converters; using Avalonia.Input; using Avalonia.Threading; using Avalonia.VisualTree; @@ -26,21 +24,6 @@ namespace SourceGit.Views protected override Type StyleKeyOverride => typeof(SelectableTextBlock); - public CommitMessagePresenter() - { - var bindings = new MultiBinding() - { - Converter = BoolConverters.And, - Bindings = new[] - { - new Binding() { Path = "IsPointerOver", Source = this }, - new Binding() { Path = "(ToolTip.Tip)", Source = this, TypeResolver = (_, name) => name == "ToolTip" ? typeof(ToolTip) : null, Converter = ObjectConverters.IsNotNull }, - } - }; - - Bind(ToolTip.IsOpenProperty, bindings); - } - protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change); From 81820e7034bc8e33da84f376096b3abf56947418 Mon Sep 17 00:00:00 2001 From: Massimo Date: Mon, 14 Apr 2025 09:18:45 +0200 Subject: [PATCH 9/9] =?UTF-8?q?refactor:=20improve=20diff=20handling=20for?= =?UTF-8?q?=20EOL=20changes=20and=20enhance=20text=20diff=E2=80=A6=20(#117?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: improve diff handling for EOL changes and enhance text diff display - Updated `Diff.cs` to streamline whitespace handling in diff arguments. - Enhanced `DiffContext.cs` to check for EOL changes when old and new hashes differ, creating a text diff if necessary. - Added support for showing end-of-line symbols in `TextDiffView.axaml.cs` options. * localization: update translations to include EOF handling in ignore whitespace messages - Modified the ignore whitespace text in multiple language files to specify that EOF changes are also ignored. - Ensured consistency across all localization files for the patch application feature. * revert: Typo in DiffResult comment * revert: update diff arguments to ignore CR at EOL in whitespace handling (like before changes) * revert: update translations to remove EOF references in Text.Apply.IgnoreWS and fixed typo in Text.Diff.IgnoreWhitespace (EOF => EOL) --------- Co-authored-by: mpagani --- src/Commands/Diff.cs | 2 +- src/Resources/Locales/de_DE.axaml | 2 +- src/Resources/Locales/en_US.axaml | 2 +- src/Resources/Locales/es_ES.axaml | 2 +- src/Resources/Locales/fr_FR.axaml | 2 +- src/Resources/Locales/it_IT.axaml | 2 +- src/Resources/Locales/ja_JP.axaml | 2 +- src/Resources/Locales/pt_BR.axaml | 2 +- src/Resources/Locales/ru_RU.axaml | 2 +- src/Resources/Locales/ta_IN.axaml | 2 +- src/Resources/Locales/zh_CN.axaml | 2 +- src/Resources/Locales/zh_TW.axaml | 2 +- src/ViewModels/DiffContext.cs | 45 ++++++++++++++++++++++++++++++- src/Views/TextDiffView.axaml.cs | 1 + 14 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 8ae6350f..a4e05ae5 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -30,7 +30,7 @@ namespace SourceGit.Commands if (ignoreWhitespace) Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --ignore-all-space --unified={unified} {opt}"; else - Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}"; + Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --unified={unified} {opt}"; } public Models.DiffResult Result() diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 25b54c60..1ceac07c 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -235,7 +235,7 @@ ALT Kopieren Dateimodus geändert - Ignoriere Leerzeichenänderungen + Ignoriere Leerzeichenänderungen und EOL LFS OBJEKT ÄNDERUNG Nächste Änderung KEINE ÄNDERUNG ODER NUR ZEILEN-ENDE ÄNDERUNGEN diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index ad71427b..7ec38670 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -241,7 +241,7 @@ Copy File Mode Changed First Difference - Ignore Whitespace Change + Ignore Whitespace Change and EOL Last Difference LFS OBJECT CHANGE Next Difference diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index e2af0860..04fdde4b 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -240,7 +240,7 @@ Copiar Modo de Archivo Cambiado Primera Diferencia - Ignorar Cambio de Espacios en Blanco + Ignorar Cambio de Espacios en Blanco y EOL Última Diferencia CAMBIO DE OBJETO LFS Siguiente Diferencia diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 83d590f5..f5679ab8 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -241,7 +241,7 @@ Copier Mode de fichier changé Première différence - Ignorer les changements d'espaces + Ignorer les changements d'espaces et EOL Dernière différence CHANGEMENT D'OBJET LFS Différence suivante diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 59bf3028..5ed81da2 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -239,7 +239,7 @@ Copia Modalità File Modificata Prima differenza - Ignora Modifiche agli Spazi + Ignora Modifiche agli Spazi e EOL Ultima differenza MODIFICA OGGETTO LFS Differenza Successiva diff --git a/src/Resources/Locales/ja_JP.axaml b/src/Resources/Locales/ja_JP.axaml index fe643b5e..1b94ed6f 100644 --- a/src/Resources/Locales/ja_JP.axaml +++ b/src/Resources/Locales/ja_JP.axaml @@ -240,7 +240,7 @@ コピー ファイルモードが変更されました 先頭の差分 - 空白の変更を無視 + 空白の変更とEOLを無視 最後の差分 LFSオブジェクトの変更 次の差分 diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 3caac3cc..e78c1a36 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -216,7 +216,7 @@ ANTIGO Copiar Modo de Arquivo Alterado - Ignorar mudanças de espaço em branco + Ignorar mudanças de espaço em branco e EOL MUDANÇA DE OBJETO LFS Próxima Diferença SEM MUDANÇAS OU APENAS MUDANÇAS DE EOL diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index ee04f4d1..dd39b34f 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -246,7 +246,7 @@ Копировать Режим файла изменён Первое различие - Игнорировать изменение пробелов + Игнорировать изменение пробелов и EOL Последнее различие ИЗМЕНЕНИЕ ОБЪЕКТА LFS Следующее различие diff --git a/src/Resources/Locales/ta_IN.axaml b/src/Resources/Locales/ta_IN.axaml index 946a8d9c..30c2244b 100644 --- a/src/Resources/Locales/ta_IN.axaml +++ b/src/Resources/Locales/ta_IN.axaml @@ -240,7 +240,7 @@ நகல் கோப்பு முறை மாற்றப்பட்டது முதல் வேறுபாடு - வெள்ளைவெளி மாற்றத்தை புறக்கணி + வெள்ளைவெளி மாற்றத்தை மற்றும் EOL புறக்கணி கடைசி வேறுபாடு பெகோஅ பொருள் மாற்றம் அடுத்த வேறுபாடு diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 35a97b6e..d8b63422 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -245,7 +245,7 @@ 复制 文件权限已变化 首个差异 - 忽略空白符号变化 + 忽略空白符号变化和EOL 最后一个差异 LFS对象变更 下一个差异 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index d71281f7..833e6610 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -245,7 +245,7 @@ 複製 檔案權限已變更 第一個差異 - 忽略空白符號變化 + 忽略空白符號變化和EOL 最後一個差異 LFS 物件變更 下一個差異 diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 6dd836bf..0feb7d77 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -207,7 +207,50 @@ namespace SourceGit.ViewModels } else { - rs = new Models.NoOrEOLChange(); + // Check if old and new hashes differ but no text changes found + if (!string.IsNullOrEmpty(latest.OldHash) && + !string.IsNullOrEmpty(latest.NewHash) && + latest.OldHash != latest.NewHash) + { + // If hashes differ but no text diff found, it's likely an EOL change + // Create a text diff to show the file content + var textDiff = new Models.TextDiff() + { + Repo = _repo, + Option = _option, + File = _option.Path + }; + // Query the file content to show + var fileContent = Commands.QueryFileContent.Run(_repo, "HEAD", _option.Path); + using var reader = new StreamReader(fileContent); + var line = string.Empty; + int lineNumber = 1; + + while ((line = reader.ReadLine()) != null) + { + textDiff.Lines.Add(new Models.TextDiffLine( + Models.TextDiffLineType.Normal, + line, + lineNumber, + lineNumber)); + + lineNumber++; + } + + if (textDiff.Lines.Count > 0) + { + textDiff.MaxLineNumber = lineNumber - 1; + rs = textDiff; + } + else + { + rs = new Models.NoOrEOLChange(); + } + } + else + { + rs = new Models.NoOrEOLChange(); + } } Dispatcher.UIThread.Post(() => diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index 7ce9f288..fa065fed 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -745,6 +745,7 @@ namespace SourceGit.Views var val = ShowHiddenSymbols; Options.ShowTabs = val; Options.ShowSpaces = val; + Options.ShowEndOfLine = val; } else if (change.Property == TabWidthProperty) {