From 054bbf7e0c683d67610a445d338c22d191f40ff2 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 09:39:03 +0800 Subject: [PATCH 01/37] enhance: do not override `core.autocrlf` configure while reading file diff (#1278) Signed-off-by: leo --- src/Commands/Diff.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index a354b816..6af0a3cc 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -28,11 +28,11 @@ namespace SourceGit.Commands Context = repo; if (ignoreWhitespace) - Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-all-space --unified={unified} {opt}"; + Args = $"diff --no-ext-diff --patch --ignore-all-space --unified={unified} {opt}"; else if (Models.DiffOption.IgnoreCRAtEOL) - Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}"; + Args = $"diff --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}"; else - Args = $"-c core.autocrlf=false diff --no-ext-diff --patch --unified={unified} {opt}"; + Args = $"diff --no-ext-diff --patch --unified={unified} {opt}"; } public Models.DiffResult Result() From df29edd8f05867b1e6688c98819094626ad3bde4 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 11:12:57 +0800 Subject: [PATCH 02/37] feature: make `--recurse-submdoules` an option while trying to checkout branch with submodules (#1272) Signed-off-by: leo --- src/Commands/Checkout.cs | 10 ++++++---- src/Models/RepositorySettings.cs | 6 ++++++ src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Checkout.cs | 16 +++++++++++++++- src/ViewModels/CreateBranch.cs | 27 +++++++++++++++++++++++++-- src/ViewModels/Repository.cs | 2 +- src/Views/Checkout.axaml | 12 ++++++++++-- src/Views/CreateBranch.axaml | 15 ++++++++++++++- 10 files changed, 80 insertions(+), 11 deletions(-) diff --git a/src/Commands/Checkout.cs b/src/Commands/Checkout.cs index c39c28ae..b0274e7d 100644 --- a/src/Commands/Checkout.cs +++ b/src/Commands/Checkout.cs @@ -11,15 +11,17 @@ namespace SourceGit.Commands Context = repo; } - public bool Branch(string branch) + public bool Branch(string branch, bool recurseSubmodules) { - Args = $"checkout --recurse-submodules --progress {branch}"; + var options = recurseSubmodules ? "--recurse-submodules" : string.Empty; + Args = $"checkout {options} --progress {branch}"; return Exec(); } - public bool Branch(string branch, string basedOn) + public bool Branch(string branch, string basedOn, bool recurseSubmodules) { - Args = $"checkout --recurse-submodules --progress -b {branch} {basedOn}"; + var options = recurseSubmodules ? "--recurse-submodules" : string.Empty; + Args = $"checkout {options} --progress -b {branch} {basedOn}"; return Exec(); } diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 34a72033..3df463b3 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -110,6 +110,12 @@ namespace SourceGit.Models set; } = true; + public bool UpdateSubmodulesOnCheckoutBranch + { + get; + set; + } = true; + public AvaloniaList HistoriesFilters { get; diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index f4c62a90..640cb8f3 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -82,6 +82,7 @@ Local Changes: Discard Stash & Reapply + Update all submodules Branch: Cherry Pick Append source to commit message diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 8ee210e9..5db542b1 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -86,6 +86,7 @@ 未提交更改 : 丢弃更改 贮藏并自动恢复 + 同时更新所有子模块 目标分支 : 挑选提交 提交信息中追加来源信息 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 7430d609..6fd380ec 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -86,6 +86,7 @@ 未提交變更: 捨棄變更 擱置變更並自動復原 + 同時更新所有子模組 目標分支: 揀選提交 提交資訊中追加來源資訊 diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index a96ac79a..67db08c9 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -15,11 +15,24 @@ namespace SourceGit.ViewModels set; } + public bool IsRecurseSubmoduleVisible + { + get; + private set; + } + + public bool RecurseSubmodules + { + get => _repo.Settings.UpdateSubmodulesOnCheckoutBranch; + set => _repo.Settings.UpdateSubmodulesOnCheckoutBranch = value; + } + public Checkout(Repository repo, string branch) { _repo = repo; Branch = branch; DiscardLocalChanges = false; + IsRecurseSubmoduleVisible = repo.Submodules.Count > 0; } public override Task Sure() @@ -30,6 +43,7 @@ namespace SourceGit.ViewModels var log = _repo.CreateLog($"Checkout '{Branch}'"); Use(log); + var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules; return Task.Run(() => { var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result(); @@ -54,7 +68,7 @@ namespace SourceGit.ViewModels } } - var rs = new Commands.Checkout(_repo.FullPath).Use(log).Branch(Branch); + var rs = new Commands.Checkout(_repo.FullPath).Use(log).Branch(Branch, updateSubmodules); if (needPopStash) rs = new Commands.Stash(_repo.FullPath).Use(log).Pop("stash@{0}"); diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index dd190e18..3a99d88c 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -28,7 +28,14 @@ namespace SourceGit.ViewModels public bool CheckoutAfterCreated { get => _repo.Settings.CheckoutBranchOnCreateBranch; - set => _repo.Settings.CheckoutBranchOnCreateBranch = value; + set + { + if (_repo.Settings.CheckoutBranchOnCreateBranch != value) + { + _repo.Settings.CheckoutBranchOnCreateBranch = value; + OnPropertyChanged(); + } + } } public bool IsBareRepository @@ -36,6 +43,18 @@ namespace SourceGit.ViewModels get => _repo.IsBare; } + public bool IsRecurseSubmoduleVisible + { + get; + private set; + } + + public bool RecurseSubmodules + { + get => _repo.Settings.UpdateSubmodulesOnCheckoutBranch; + set => _repo.Settings.UpdateSubmodulesOnCheckoutBranch = value; + } + public CreateBranch(Repository repo, Models.Branch branch) { _repo = repo; @@ -48,6 +67,7 @@ namespace SourceGit.ViewModels BasedOn = branch; DiscardLocalChanges = false; + IsRecurseSubmoduleVisible = repo.Submodules.Count > 0; } public CreateBranch(Repository repo, Models.Commit commit) @@ -57,6 +77,7 @@ namespace SourceGit.ViewModels BasedOn = commit; DiscardLocalChanges = false; + IsRecurseSubmoduleVisible = repo.Submodules.Count > 0; } public CreateBranch(Repository repo, Models.Tag tag) @@ -66,6 +87,7 @@ namespace SourceGit.ViewModels BasedOn = tag; DiscardLocalChanges = false; + IsRecurseSubmoduleVisible = repo.Submodules.Count > 0; } public static ValidationResult ValidateBranchName(string name, ValidationContext ctx) @@ -92,6 +114,7 @@ namespace SourceGit.ViewModels var log = _repo.CreateLog($"Create Branch '{fixedName}'"); Use(log); + var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules; return Task.Run(() => { bool succ; @@ -119,7 +142,7 @@ namespace SourceGit.ViewModels } } - succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(fixedName, _baseOnRevision); + succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(fixedName, _baseOnRevision, updateSubmodules); if (needPopStash) new Commands.Stash(_repo.FullPath).Use(log).Pop("stash@{0}"); } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 289d890f..5e8bd40d 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1154,7 +1154,7 @@ namespace SourceGit.ViewModels if (branch.IsLocal) { - if (_localChangesCount > 0) + if (_localChangesCount > 0 || _submodules.Count > 0) ShowPopup(new Checkout(this, branch.Name)); else ShowAndStartPopup(new Checkout(this, branch.Name)); diff --git a/src/Views/Checkout.axaml b/src/Views/Checkout.axaml index 3cdfd94e..42b9cec5 100644 --- a/src/Views/Checkout.axaml +++ b/src/Views/Checkout.axaml @@ -17,6 +17,7 @@ + + Content="{DynamicResource Text.Checkout.LocalChanges.Discard}"/> + + diff --git a/src/Views/CreateBranch.axaml b/src/Views/CreateBranch.axaml index a5f1f212..e77f8751 100644 --- a/src/Views/CreateBranch.axaml +++ b/src/Views/CreateBranch.axaml @@ -14,7 +14,7 @@ - + + + + + + + + + + + From 4bc5b90e6b721c562fa1f57a35e9f002962eeb2c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 6 May 2025 03:13:13 +0000 Subject: [PATCH 03/37] doc: Update translation status and sort locale files (cherry picked from commit 15445d02379020144239886bc87380ae38c2018a) --- TRANSLATION.md | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/TRANSLATION.md b/TRANSLATION.md index facab0ab..242b950a 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -6,7 +6,7 @@ This document shows the translation status of each locale file in the repository ### ![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen) -### ![de__DE](https://img.shields.io/badge/de__DE-95.07%25-yellow) +### ![de__DE](https://img.shields.io/badge/de__DE-94.95%25-yellow)
Missing keys in de_DE.axaml @@ -19,6 +19,7 @@ This document shows the translation status of each locale file in the repository - Text.Bisect.Skip - Text.Bisect.WaitingForRange - Text.BranchUpstreamInvalid +- Text.Checkout.RecurseSubmodules - Text.CommitCM.CopyAuthor - Text.CommitCM.CopyCommitter - Text.CommitCM.CopySubject @@ -52,9 +53,16 @@ This document shows the translation status of each locale file in the repository
-### ![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen) +### ![es__ES](https://img.shields.io/badge/es__ES-99.87%25-yellow) -### ![fr__FR](https://img.shields.io/badge/fr__FR-96.37%25-yellow) +
+Missing keys in es_ES.axaml + +- Text.Checkout.RecurseSubmodules + +
+ +### ![fr__FR](https://img.shields.io/badge/fr__FR-96.24%25-yellow)
Missing keys in fr_FR.axaml @@ -66,6 +74,7 @@ This document shows the translation status of each locale file in the repository - Text.Bisect.Good - Text.Bisect.Skip - Text.Bisect.WaitingForRange +- Text.Checkout.RecurseSubmodules - Text.CommitCM.CopyAuthor - Text.CommitCM.CopyCommitter - Text.CommitCM.CopySubject @@ -90,7 +99,7 @@ This document shows the translation status of each locale file in the repository
-### ![it__IT](https://img.shields.io/badge/it__IT-96.11%25-yellow) +### ![it__IT](https://img.shields.io/badge/it__IT-95.98%25-yellow)
Missing keys in it_IT.axaml @@ -102,6 +111,7 @@ This document shows the translation status of each locale file in the repository - Text.Bisect.Good - Text.Bisect.Skip - Text.Bisect.WaitingForRange +- Text.Checkout.RecurseSubmodules - Text.CommitCM.CopyAuthor - Text.CommitCM.CopyCommitter - Text.CommitCM.CopySubject @@ -128,7 +138,7 @@ This document shows the translation status of each locale file in the repository
-### ![ja__JP](https://img.shields.io/badge/ja__JP-96.11%25-yellow) +### ![ja__JP](https://img.shields.io/badge/ja__JP-95.98%25-yellow)
Missing keys in ja_JP.axaml @@ -140,6 +150,7 @@ This document shows the translation status of each locale file in the repository - Text.Bisect.Good - Text.Bisect.Skip - Text.Bisect.WaitingForRange +- Text.Checkout.RecurseSubmodules - Text.CommitCM.CopyAuthor - Text.CommitCM.CopyCommitter - Text.CommitCM.CopySubject @@ -166,7 +177,7 @@ This document shows the translation status of each locale file in the repository
-### ![pt__BR](https://img.shields.io/badge/pt__BR-87.68%25-yellow) +### ![pt__BR](https://img.shields.io/badge/pt__BR-87.56%25-yellow)
Missing keys in pt_BR.axaml @@ -187,6 +198,7 @@ This document shows the translation status of each locale file in the repository - Text.BranchCM.CustomAction - Text.BranchCM.MergeMultiBranches - Text.BranchUpstreamInvalid +- Text.Checkout.RecurseSubmodules - Text.Clone.RecurseSubmodules - Text.CommitCM.CopyAuthor - Text.CommitCM.CopyCommitter @@ -269,9 +281,16 @@ This document shows the translation status of each locale file in the repository
-### ![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen) +### ![ru__RU](https://img.shields.io/badge/ru__RU-99.87%25-yellow) -### ![ta__IN](https://img.shields.io/badge/ta__IN-96.37%25-yellow) +
+Missing keys in ru_RU.axaml + +- Text.Checkout.RecurseSubmodules + +
+ +### ![ta__IN](https://img.shields.io/badge/ta__IN-96.24%25-yellow)
Missing keys in ta_IN.axaml @@ -283,6 +302,7 @@ This document shows the translation status of each locale file in the repository - Text.Bisect.Good - Text.Bisect.Skip - Text.Bisect.WaitingForRange +- Text.Checkout.RecurseSubmodules - Text.CommitCM.CopyAuthor - Text.CommitCM.CopyCommitter - Text.CommitCM.CopySubject @@ -307,7 +327,7 @@ This document shows the translation status of each locale file in the repository
-### ![uk__UA](https://img.shields.io/badge/uk__UA-97.54%25-yellow) +### ![uk__UA](https://img.shields.io/badge/uk__UA-97.41%25-yellow)
Missing keys in uk_UA.axaml @@ -319,6 +339,7 @@ This document shows the translation status of each locale file in the repository - Text.Bisect.Good - Text.Bisect.Skip - Text.Bisect.WaitingForRange +- Text.Checkout.RecurseSubmodules - Text.CommitCM.CopyAuthor - Text.CommitCM.CopyCommitter - Text.CommitCM.CopySubject From eae6d1078487dce25f160b630b0fc7f7645595c8 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 12:17:17 +0800 Subject: [PATCH 04/37] enhance: only log exception in popup task (#1281) Signed-off-by: leo --- src/App.axaml.cs | 2 +- src/ViewModels/LauncherPage.cs | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index c54b616d..6e45164d 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -78,7 +78,7 @@ namespace SourceGit return builder; } - private static void LogException(Exception ex) + public static void LogException(Exception ex) { if (ex == null) return; diff --git a/src/ViewModels/LauncherPage.cs b/src/ViewModels/LauncherPage.cs index b97ef6f7..3affe71d 100644 --- a/src/ViewModels/LauncherPage.cs +++ b/src/ViewModels/LauncherPage.cs @@ -100,23 +100,32 @@ namespace SourceGit.ViewModels public async void ProcessPopup() { - if (_popup is { InProgress: false }) + if (_popup is { InProgress: false } dump) { - if (!_popup.Check()) + if (!dump.Check()) return; - _popup.InProgress = true; - var task = _popup.Sure(); + dump.InProgress = true; + var task = dump.Sure(); + var finished = false; if (task != null) { - var finished = await task; - _popup.InProgress = false; + try + { + finished = await task; + } + catch (Exception e) + { + App.LogException(e); + } + + dump.InProgress = false; if (finished) Popup = null; } else { - _popup.InProgress = false; + dump.InProgress = false; Popup = null; } } From e4e2f7b3a7cbad3e1203f0b0fd7a9696e05a2235 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 14:49:54 +0800 Subject: [PATCH 05/37] ux: use smaller font size for inline code in commit subject Signed-off-by: leo --- src/Views/CommitSubjectPresenter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Views/CommitSubjectPresenter.cs b/src/Views/CommitSubjectPresenter.cs index 86e0fd54..38e964be 100644 --- a/src/Views/CommitSubjectPresenter.cs +++ b/src/Views/CommitSubjectPresenter.cs @@ -299,7 +299,7 @@ namespace SourceGit.Views CultureInfo.CurrentCulture, FlowDirection.LeftToRight, codeTypeface, - fontSize, + fontSize - 0.5, foreground); _inlines.Add(new Inline(x, link, elem)); x += link.WidthIncludingTrailingWhitespace + 8; From 93a5d7baea923483fe10fbae8414e59a934f7c11 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 15:51:57 +0800 Subject: [PATCH 06/37] feature: supports to visit remote repository in web browser (#1265) - combine `Open in File Manager`, `Open in Terminal` and `Open with external editor` into one dropdown menu - add `Visit $REMOTE in Browser` Signed-off-by: leo --- src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Repository.cs | 96 ++++++++++++++++++++++--------- src/Views/RepositoryToolbar.axaml | 10 +--- 5 files changed, 73 insertions(+), 36 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 640cb8f3..0ebeeeb0 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -626,6 +626,7 @@ Open in Terminal Use relative time in histories View Logs + Visit '{0}' in Browser WORKTREES ADD WORKTREE PRUNE diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 5db542b1..6bf7f5d1 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -630,6 +630,7 @@ 在终端中打开 在提交列表中使用相对时间 查看命令日志 + 访问远程仓库 '{0}' 工作树列表 新增工作树 清理 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 6fd380ec..9ed35c8a 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -630,6 +630,7 @@ 在終端機中開啟 在提交列表中使用相對時間 檢視 Git 指令記錄 + 檢視遠端存放庫 '{0}' 工作區列表 新增工作區 清理 diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 5e8bd40d..bf084fb0 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -583,45 +583,87 @@ namespace SourceGit.ViewModels Task.Run(RefreshStashes); } - public void OpenInFileManager() - { - Native.OS.OpenInFileManager(_fullpath); - } - - public void OpenInTerminal() - { - Native.OS.OpenTerminal(_fullpath); - } - public ContextMenu CreateContextMenuForExternalTools() { - var tools = Native.OS.ExternalTools; - if (tools.Count == 0) - { - App.RaiseException(_fullpath, "No available external editors found!"); - return null; - } - var menu = new ContextMenu(); menu.Placement = PlacementMode.BottomEdgeAlignedLeft; + RenderOptions.SetBitmapInterpolationMode(menu, BitmapInterpolationMode.HighQuality); + RenderOptions.SetEdgeMode(menu, EdgeMode.Antialias); + RenderOptions.SetTextRenderingMode(menu, TextRenderingMode.Antialias); - foreach (var tool in tools) + var explore = new MenuItem(); + explore.Header = App.Text("Repository.Explore"); + explore.Icon = App.CreateMenuIcon("Icons.Explore"); + explore.Click += (_, e) => { - var dupTool = tool; + Native.OS.OpenInFileManager(_fullpath); + e.Handled = true; + }; - var item = new MenuItem(); - item.Header = App.Text("Repository.OpenIn", dupTool.Name); - item.Icon = new Image { Width = 16, Height = 16, Source = dupTool.IconImage }; - item.Click += (_, e) => + var terminal = new MenuItem(); + terminal.Header = App.Text("Repository.Terminal"); + terminal.Icon = App.CreateMenuIcon("Icons.Terminal"); + terminal.Click += (_, e) => + { + Native.OS.OpenTerminal(_fullpath); + e.Handled = true; + }; + + menu.Items.Add(explore); + menu.Items.Add(terminal); + + var tools = Native.OS.ExternalTools; + if (tools.Count > 0) + { + menu.Items.Add(new MenuItem() { Header = "-" }); + + foreach (var tool in Native.OS.ExternalTools) { - dupTool.Open(_fullpath); - e.Handled = true; - }; + var dupTool = tool; - menu.Items.Add(item); + var item = new MenuItem(); + item.Header = App.Text("Repository.OpenIn", dupTool.Name); + item.Icon = new Image { Width = 16, Height = 16, Source = dupTool.IconImage }; + item.Click += (_, e) => + { + dupTool.Open(_fullpath); + e.Handled = true; + }; + + menu.Items.Add(item); + } } + var urls = new Dictionary(); + foreach (var r in _remotes) + { + if (r.TryGetVisitURL(out var visit)) + urls.Add(r.Name, visit); + } + + if (urls.Count > 0) + { + menu.Items.Add(new MenuItem() { Header = "-" }); + + foreach (var url in urls) + { + var name = url.Key; + var addr = url.Value; + + var item = new MenuItem(); + item.Header = App.Text("Repository.Visit", name); + item.Icon = App.CreateMenuIcon("Icons.Remotes"); + item.Click += (_, e) => + { + Native.OS.OpenBrowser(addr); + e.Handled = true; + }; + + menu.Items.Add(item); + } + } + return menu; } diff --git a/src/Views/RepositoryToolbar.axaml b/src/Views/RepositoryToolbar.axaml index 85b2ad76..208ff725 100644 --- a/src/Views/RepositoryToolbar.axaml +++ b/src/Views/RepositoryToolbar.axaml @@ -9,16 +9,8 @@ x:DataType="vm:Repository"> - - - - + - + - + diff --git a/src/Views/Repository.axaml.cs b/src/Views/Repository.axaml.cs index a9f5bfee..3e30d161 100644 --- a/src/Views/Repository.axaml.cs +++ b/src/Views/Repository.axaml.cs @@ -403,6 +403,28 @@ namespace SourceGit.Views e.Handled = true; } + private void OnOpenSortLocalBranchMenu(object sender, RoutedEventArgs e) + { + if (sender is Button button && DataContext is ViewModels.Repository repo) + { + var menu = repo.CreateContextMenuForBranchSortMode(true); + menu?.Open(button); + } + + e.Handled = true; + } + + private void OnOpenSortRemoteBranchMenu(object sender, RoutedEventArgs e) + { + if (sender is Button button && DataContext is ViewModels.Repository repo) + { + var menu = repo.CreateContextMenuForBranchSortMode(false); + menu?.Open(button); + } + + e.Handled = true; + } + private void OnOpenSortTagMenu(object sender, RoutedEventArgs e) { if (sender is Button button && DataContext is ViewModels.Repository repo) From c8e21673e48e79f551ef4fd61635a9dde3bbabcb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 6 May 2025 10:24:59 +0000 Subject: [PATCH 09/37] doc: Update translation status and sort locale files --- TRANSLATION.md | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/TRANSLATION.md b/TRANSLATION.md index 2632bc4f..9b499ce2 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -6,7 +6,7 @@ This document shows the translation status of each locale file in the repository ### ![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen) -### ![de__DE](https://img.shields.io/badge/de__DE-94.83%25-yellow) +### ![de__DE](https://img.shields.io/badge/de__DE-94.46%25-yellow)
Missing keys in de_DE.axaml @@ -38,6 +38,9 @@ This document shows the translation status of each locale file in the repository - Text.Preferences.Appearance.EditorTabWidth - Text.Preferences.General.ShowTagsInGraph - Text.Preferences.Git.IgnoreCRAtEOLInDiff +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.Search.ByContent - Text.Repository.ViewLogs - Text.Repository.Visit @@ -54,17 +57,20 @@ This document shows the translation status of each locale file in the repository
-### ![es__ES](https://img.shields.io/badge/es__ES-99.74%25-yellow) +### ![es__ES](https://img.shields.io/badge/es__ES-99.36%25-yellow)
Missing keys in es_ES.axaml - Text.Checkout.RecurseSubmodules +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.Visit
-### ![fr__FR](https://img.shields.io/badge/fr__FR-96.12%25-yellow) +### ![fr__FR](https://img.shields.io/badge/fr__FR-95.75%25-yellow)
Missing keys in fr_FR.axaml @@ -87,6 +93,9 @@ This document shows the translation status of each locale file in the repository - Text.ConfirmEmptyCommit.StageAllThenCommit - Text.ConfirmEmptyCommit.WithLocalChanges - Text.Preferences.Git.IgnoreCRAtEOLInDiff +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.Search.ByContent - Text.Repository.ViewLogs - Text.Repository.Visit @@ -102,7 +111,7 @@ This document shows the translation status of each locale file in the repository
-### ![it__IT](https://img.shields.io/badge/it__IT-95.86%25-yellow) +### ![it__IT](https://img.shields.io/badge/it__IT-95.49%25-yellow)
Missing keys in it_IT.axaml @@ -127,6 +136,9 @@ This document shows the translation status of each locale file in the repository - Text.CopyFullPath - Text.Preferences.General.ShowTagsInGraph - Text.Preferences.Git.IgnoreCRAtEOLInDiff +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.Search.ByContent - Text.Repository.ViewLogs - Text.Repository.Visit @@ -142,7 +154,7 @@ This document shows the translation status of each locale file in the repository
-### ![ja__JP](https://img.shields.io/badge/ja__JP-95.86%25-yellow) +### ![ja__JP](https://img.shields.io/badge/ja__JP-95.49%25-yellow)
Missing keys in ja_JP.axaml @@ -165,6 +177,9 @@ This document shows the translation status of each locale file in the repository - Text.ConfirmEmptyCommit.StageAllThenCommit - Text.ConfirmEmptyCommit.WithLocalChanges - Text.Preferences.Git.IgnoreCRAtEOLInDiff +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.FilterCommits - Text.Repository.Search.ByContent - Text.Repository.Tags.OrderByNameDes @@ -182,7 +197,7 @@ This document shows the translation status of each locale file in the repository
-### ![pt__BR](https://img.shields.io/badge/pt__BR-87.45%25-yellow) +### ![pt__BR](https://img.shields.io/badge/pt__BR-87.11%25-yellow)
Missing keys in pt_BR.axaml @@ -249,6 +264,9 @@ This document shows the translation status of each locale file in the repository - Text.Preferences.General.ShowTagsInGraph - Text.Preferences.Git.IgnoreCRAtEOLInDiff - Text.Preferences.Git.SSLVerify +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.FilterCommits - Text.Repository.HistoriesLayout - Text.Repository.HistoriesLayout.Horizontal @@ -287,17 +305,20 @@ This document shows the translation status of each locale file in the repository
-### ![ru__RU](https://img.shields.io/badge/ru__RU-99.74%25-yellow) +### ![ru__RU](https://img.shields.io/badge/ru__RU-99.36%25-yellow)
Missing keys in ru_RU.axaml - Text.Checkout.RecurseSubmodules +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.Visit
-### ![ta__IN](https://img.shields.io/badge/ta__IN-96.12%25-yellow) +### ![ta__IN](https://img.shields.io/badge/ta__IN-95.75%25-yellow)
Missing keys in ta_IN.axaml @@ -320,6 +341,9 @@ This document shows the translation status of each locale file in the repository - Text.ConfirmEmptyCommit.StageAllThenCommit - Text.ConfirmEmptyCommit.WithLocalChanges - Text.Preferences.Git.IgnoreCRAtEOLInDiff +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.Search.ByContent - Text.Repository.ViewLogs - Text.Repository.Visit @@ -335,7 +359,7 @@ This document shows the translation status of each locale file in the repository
-### ![uk__UA](https://img.shields.io/badge/uk__UA-97.28%25-yellow) +### ![uk__UA](https://img.shields.io/badge/uk__UA-96.91%25-yellow)
Missing keys in uk_UA.axaml @@ -354,6 +378,9 @@ This document shows the translation status of each locale file in the repository - Text.CommitMessageTextBox.SubjectCount - Text.ConfigureWorkspace.Name - Text.Preferences.Git.IgnoreCRAtEOLInDiff +- Text.Repository.BranchSort +- Text.Repository.BranchSort.ByCommitterDate +- Text.Repository.BranchSort.ByName - Text.Repository.Search.ByContent - Text.Repository.ViewLogs - Text.Repository.Visit From bbc840a5cb98c53dd4d831a34b1ad999b4a3642c Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 19:26:06 +0800 Subject: [PATCH 10/37] perf: set/update `TimeToSort` while creating branch nodes Signed-off-by: leo --- src/ViewModels/BranchTreeNode.cs | 40 +++++--------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/src/ViewModels/BranchTreeNode.cs b/src/ViewModels/BranchTreeNode.cs index 005d8b90..d0289f6a 100644 --- a/src/ViewModels/BranchTreeNode.cs +++ b/src/ViewModels/BranchTreeNode.cs @@ -120,28 +120,19 @@ namespace SourceGit.ViewModels folders.Clear(); if (_localSortMode == Models.BranchSortMode.Name) - { SortNodesByName(_locals); - } else - { - SetTimeToSortRecusive(_locals); SortNodesByTime(_locals); - } if (_remoteSortMode == Models.BranchSortMode.Name) - { SortNodesByName(_remotes); - } else - { - SetTimeToSortRecusive(_remotes); SortNodesByTime(_remotes); - } } private void MakeBranchNode(Models.Branch branch, List roots, Dictionary folders, string prefix, bool bForceExpanded) { + var time = branch.CommitterDate; var fullpath = $"{prefix}/{branch.Name}"; var sepIdx = branch.Name.IndexOf('/', StringComparison.Ordinal); if (sepIdx == -1 || branch.IsDetachedHead) @@ -152,7 +143,7 @@ namespace SourceGit.ViewModels Path = fullpath, Backend = branch, IsExpanded = false, - TimeToSort = branch.CommitterDate, + TimeToSort = time, }); return; } @@ -167,6 +158,7 @@ namespace SourceGit.ViewModels if (folders.TryGetValue(folder, out var val)) { lastFolder = val; + lastFolder.TimeToSort = Math.Max(lastFolder.TimeToSort, time); if (!lastFolder.IsExpanded) lastFolder.IsExpanded |= (branch.IsCurrent || _expanded.Contains(folder)); } @@ -177,6 +169,7 @@ namespace SourceGit.ViewModels Name = name, Path = folder, IsExpanded = bForceExpanded || branch.IsCurrent || _expanded.Contains(folder), + TimeToSort = time, }; roots.Add(lastFolder); folders.Add(folder, lastFolder); @@ -188,6 +181,7 @@ namespace SourceGit.ViewModels Name = name, Path = folder, IsExpanded = bForceExpanded || branch.IsCurrent || _expanded.Contains(folder), + TimeToSort = time, }; lastFolder.Children.Add(cur); folders.Add(folder, cur); @@ -204,7 +198,7 @@ namespace SourceGit.ViewModels Path = fullpath, Backend = branch, IsExpanded = false, - TimeToSort = branch.CommitterDate, + TimeToSort = time, }); } @@ -253,28 +247,6 @@ namespace SourceGit.ViewModels SortNodesByTime(node.Children); } - private ulong SetTimeToSortRecusive(List nodes) - { - var recent = (ulong)0; - - foreach (var node in nodes) - { - if (node.Backend is Models.Branch) - { - recent = Math.Max(recent, node.TimeToSort); - continue; - } - - var time = SetTimeToSortRecusive(node.Children); - recent = Math.Max(recent, time); - - if (node.Backend is not Models.Remote) - node.TimeToSort = time; - } - - return recent; - } - private readonly Models.BranchSortMode _localSortMode = Models.BranchSortMode.Name; private readonly Models.BranchSortMode _remoteSortMode = Models.BranchSortMode.Name; private readonly List _locals = new List(); From ddf643c081791002fbea743a3e1a3fb911769660 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 20:52:43 +0800 Subject: [PATCH 11/37] ux: new style for revision/branch compare targets Signed-off-by: leo --- src/Views/BranchCompare.axaml | 6 +++--- src/Views/RevisionCompare.axaml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Views/BranchCompare.axaml b/src/Views/BranchCompare.axaml index 4f6f312e..1fe66e9b 100644 --- a/src/Views/BranchCompare.axaml +++ b/src/Views/BranchCompare.axaml @@ -46,7 +46,7 @@ - + - + - + @@ -47,7 +47,7 @@ - + From a413df6f89841a93320b3b657368cfd7793b391f Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 6 May 2025 20:56:45 +0800 Subject: [PATCH 12/37] code_style: run `dotnet format` Signed-off-by: leo --- src/ViewModels/LauncherPage.cs | 2 +- src/ViewModels/Repository.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ViewModels/LauncherPage.cs b/src/ViewModels/LauncherPage.cs index 3affe71d..8a59d246 100644 --- a/src/ViewModels/LauncherPage.cs +++ b/src/ViewModels/LauncherPage.cs @@ -118,7 +118,7 @@ namespace SourceGit.ViewModels { App.LogException(e); } - + dump.InProgress = false; if (finished) Popup = null; diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 54070cf5..8661cae2 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -662,7 +662,7 @@ namespace SourceGit.ViewModels menu.Items.Add(item); } - } + } return menu; } From 417ab3ecc276547e5e7ef34d0d4861cb64a20b50 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 7 May 2025 09:52:26 +0800 Subject: [PATCH 13/37] ux: layout for revision compare targets Signed-off-by: leo --- src/Views/RevisionCompare.axaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Views/RevisionCompare.axaml b/src/Views/RevisionCompare.axaml index 8f5ebeee..6367c866 100644 --- a/src/Views/RevisionCompare.axaml +++ b/src/Views/RevisionCompare.axaml @@ -28,12 +28,12 @@ - + - + From 6b050fa55741652e0fcfeb6d7fc4049dedbcf611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20G=C3=B6ttfert?= <45085620+ChrisGoettfert@users.noreply.github.com> Date: Wed, 7 May 2025 13:08:39 +0200 Subject: [PATCH 14/37] localization: updated german translations (#1284) --- TRANSLATION.md | 44 ------------------------------- src/Resources/Locales/de_DE.axaml | 43 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/TRANSLATION.md b/TRANSLATION.md index 9b499ce2..29a9b46f 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -11,50 +11,6 @@ This document shows the translation status of each locale file in the repository
Missing keys in de_DE.axaml -- Text.Bisect -- Text.Bisect.Abort -- Text.Bisect.Bad -- Text.Bisect.Detecting -- Text.Bisect.Good -- Text.Bisect.Skip -- Text.Bisect.WaitingForRange -- Text.BranchUpstreamInvalid -- Text.Checkout.RecurseSubmodules -- Text.CommitCM.CopyAuthor -- Text.CommitCM.CopyCommitter -- Text.CommitCM.CopySubject -- Text.CommitMessageTextBox.SubjectCount -- Text.Configure.CustomAction.WaitForExit -- Text.Configure.Git.PreferredMergeMode -- Text.Configure.IssueTracker.AddSampleAzure -- Text.ConfirmEmptyCommit.Continue -- Text.ConfirmEmptyCommit.NoLocalChanges -- Text.ConfirmEmptyCommit.StageAllThenCommit -- Text.ConfirmEmptyCommit.WithLocalChanges -- Text.CopyFullPath -- Text.Diff.First -- Text.Diff.Last -- Text.Preferences.AI.Streaming -- Text.Preferences.Appearance.EditorTabWidth -- Text.Preferences.General.ShowTagsInGraph -- Text.Preferences.Git.IgnoreCRAtEOLInDiff -- Text.Repository.BranchSort -- Text.Repository.BranchSort.ByCommitterDate -- Text.Repository.BranchSort.ByName -- Text.Repository.Search.ByContent -- Text.Repository.ViewLogs -- Text.Repository.Visit -- Text.StashCM.SaveAsPatch -- Text.ViewLogs -- Text.ViewLogs.Clear -- Text.ViewLogs.CopyLog -- Text.ViewLogs.Delete -- Text.WorkingCopy.ConfirmCommitWithFilter -- Text.WorkingCopy.Conflicts.OpenExternalMergeTool -- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts -- Text.WorkingCopy.Conflicts.UseMine -- Text.WorkingCopy.Conflicts.UseTheirs -
### ![es__ES](https://img.shields.io/badge/es__ES-99.36%25-yellow) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 8eb49a3e..30750931 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -40,6 +40,13 @@ KEINE ALS UNVERÄNDERT ANGENOMMENEN DATEIEN ENTFERNEN BINÄRE DATEI NICHT UNTERSTÜTZT!!! + Bisect + Abbrechen + Schlecht + Bisecting. Ist der aktuelle HEAD gut oder fehlerhaft? + Gut + Überspringen + Bisecting. Aktuellen Commit als gut oder schlecht markieren und einen anderen auschecken. Blame BLAME WIRD BEI DIESER DATEI NICHT UNTERSTÜTZT!!! Auschecken von ${0}$... @@ -62,6 +69,7 @@ Benenne ${0}$ um... Setze verfolgten Branch... Branch Vergleich + Ungültiger upstream! Bytes ABBRECHEN Auf Vorgänger-Revision zurücksetzen @@ -78,6 +86,7 @@ Lokale Änderungen: Verwerfen Stashen & wieder anwenden + Alle Submodule updaten Branch: Cherry Pick Quelle an Commit-Nachricht anhängen @@ -102,8 +111,11 @@ Mehrere cherry-picken Mit HEAD vergleichen Mit Worktree vergleichen + Author + Committer Information SHA + Betreff Benutzerdefinierte Aktion Interactives Rebase von ${0}$ auf diesen Commit Merge in ${0}$ hinein @@ -135,6 +147,7 @@ SHA Im Browser öffnen Details + Betreff Commit-Nachricht Repository Einstellungen COMMIT TEMPLATE @@ -149,13 +162,16 @@ Branch Commit Repository + Auf Beenden der Aktion warten Email Adresse Email Adresse GIT Remotes automatisch fetchen Minute(n) Standard Remote + Bevorzugter Merge Modus TICKETSYSTEM + Beispiel Azure DevOps Rule hinzufügen Beispiel für Gitee Issue Regel einfügen Beispiel für Gitee Pull Request Regel einfügen Beispiel für Github-Regel hinzufügen @@ -178,6 +194,10 @@ Farbe Name Zuletzt geöffnete Tabs beim Starten wiederherstellen + WEITER + Leerer Commit erkannt! Möchtest du trotzdem fortfahren (--allow-empty)? + ALLES STAGEN & COMMITTEN + Leerer Commit erkannt! Möchtest du trotzdem fortfahren (--allow-empty) oder alle Änderungen stagen und dann committen? Konventionelle Commit-Hilfe Breaking Change: Geschlossenes Ticket: @@ -187,6 +207,7 @@ Typ der Änderung: Kopieren Kopiere gesamten Text + Ganzen Pfad kopieren Pfad kopieren Branch erstellen... Basierend auf: @@ -236,7 +257,9 @@ ALT Kopieren Dateimodus geändert + Erste Differenz Ignoriere Leerzeichenänderungen + Letzte Differenz LFS OBJEKT ÄNDERUNG Nächste Änderung KEINE ÄNDERUNG ODER NUR ZEILEN-ENDE ÄNDERUNGEN @@ -447,8 +470,10 @@ Modell Name Server + Streaming aktivieren DARSTELLUNG Standardschriftart + Editor Tab Breite Schriftgröße Standard Texteditor @@ -469,6 +494,7 @@ Commit-Historie Zeige Autor Zeitpunkt anstatt Commit Zeitpunkt Zeige Nachfolger in den Commit Details + Zeige Tags im Commit Graph Längenvorgabe für Commit-Nachrichten GIT Aktiviere Auto-CRLF @@ -476,6 +502,7 @@ Benutzer Email Globale Git Benutzer Email Aktivere --prune beim fetchen + Aktiviere --ignore-cr-at-eol beim Unterschied Diese App setzt Git (>= 2.23.0) voraus Installationspfad Aktiviere HTTP SSL Verifizierung @@ -549,6 +576,9 @@ Branch: ABBRECHEN Änderungen automatisch von Remote fetchen... + Sortieren + Nach Commit Datum + Nach Name Aufräumen (GC & Prune) Führt `git gc` auf diesem Repository aus. Filter aufheben @@ -583,6 +613,7 @@ Commit suchen Autor Committer + Inhalt Dateiname Commit-Nachricht SHA @@ -601,6 +632,8 @@ Sortiere Öffne im Terminal Verwende relative Zeitangaben in Verlauf + Logs ansehen + Öffne '{0}' im Browser WORKTREES WORKTREE HINZUFÜGEN PRUNE @@ -651,6 +684,7 @@ Lokale Änderungen stashen Anwenden Entfernen + Als Path speichern... Stash entfernen Entfernen: Stashes @@ -685,6 +719,10 @@ Submodul: Verwende `--remote` Option URL: + Logs + ALLES LÖSCHEN + Kopieren + Löschen Warnung Willkommensseite Erstelle Gruppe @@ -714,8 +752,13 @@ Klick-Ereignis auslösen Commit (Bearbeitung) Alle Änderungen stagen und committen + Du hast {0} Datei(en) gestaged, aber nur {1} werden angezeigt ({2} sind herausgefiltert). Willst du trotzdem fortfahren? KONFLIKTE ERKANNT + EXTERNES MERGE-TOOL ÖFFNEN + ALLE KONFLIKTE IN EXTERNEM MERGE-TOOL ÖFFNEN DATEI KONFLIKTE GELÖST + MEINE VERSION VERWENDEN + DEREN VERSION VERWENDEN NICHT-VERFOLGTE DATEIEN INKLUDIEREN KEINE BISHERIGEN COMMIT-NACHRICHTEN KEINE COMMIT TEMPLATES From 0a7b9733886d035b45c180c1211c4346bb3b6689 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 May 2025 11:08:51 +0000 Subject: [PATCH 15/37] doc: Update translation status and sort locale files --- TRANSLATION.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/TRANSLATION.md b/TRANSLATION.md index 29a9b46f..7b7bf212 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -6,12 +6,7 @@ This document shows the translation status of each locale file in the repository ### ![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen) -### ![de__DE](https://img.shields.io/badge/de__DE-94.46%25-yellow) - -
-Missing keys in de_DE.axaml - -
+### ![de__DE](https://img.shields.io/badge/de__DE-%E2%88%9A-brightgreen) ### ![es__ES](https://img.shields.io/badge/es__ES-99.36%25-yellow) From 6df38ad97043dc2babee6f1709e56297d0d3629b Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 7 May 2025 20:23:06 +0800 Subject: [PATCH 16/37] ux: new style for inline code in commit subject Signed-off-by: leo --- src/Resources/Themes.axaml | 4 ++-- src/Views/CommitSubjectPresenter.cs | 37 ++++++++++++++++++----------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Resources/Themes.axaml b/src/Resources/Themes.axaml index f33e71d2..3194c8c3 100644 --- a/src/Resources/Themes.axaml +++ b/src/Resources/Themes.axaml @@ -25,7 +25,7 @@ #A7E1A7 #F19B9D #0000EE - #FFE5E5E5 + #FFE4E4E4 @@ -52,7 +52,7 @@ #A0308D3C #A09F4247 #4DAAFC - #FF2E2E2E + #FF383838 diff --git a/src/Views/CommitSubjectPresenter.cs b/src/Views/CommitSubjectPresenter.cs index 38e964be..18902462 100644 --- a/src/Views/CommitSubjectPresenter.cs +++ b/src/Views/CommitSubjectPresenter.cs @@ -104,23 +104,32 @@ namespace SourceGit.Views if (_inlines.Count == 0) return; - var height = Bounds.Height; - var width = Bounds.Width; - foreach (var inline in _inlines) + var ro = new RenderOptions() { - if (inline.X > width) - return; + TextRenderingMode = TextRenderingMode.SubpixelAntialias, + EdgeMode = EdgeMode.Antialias + }; - if (inline.Element is { Type: Models.InlineElementType.Code }) + using (context.PushRenderOptions(ro)) + { + var height = Bounds.Height; + var width = Bounds.Width; + foreach (var inline in _inlines) { - var rect = new Rect(inline.X, (height - inline.Text.Height - 2) * 0.5, inline.Text.WidthIncludingTrailingWhitespace + 8, inline.Text.Height + 2); - var roundedRect = new RoundedRect(rect, new CornerRadius(4)); - context.DrawRectangle(InlineCodeBackground, null, roundedRect); - context.DrawText(inline.Text, new Point(inline.X + 4, (height - inline.Text.Height) * 0.5)); - } - else - { - context.DrawText(inline.Text, new Point(inline.X, (height - inline.Text.Height) * 0.5)); + if (inline.X > width) + return; + + if (inline.Element is { Type: Models.InlineElementType.Code }) + { + var rect = new Rect(inline.X, (height - inline.Text.Height - 2) * 0.5, inline.Text.WidthIncludingTrailingWhitespace + 8, inline.Text.Height + 2); + var roundedRect = new RoundedRect(rect, new CornerRadius(4)); + context.DrawRectangle(InlineCodeBackground, null, roundedRect); + context.DrawText(inline.Text, new Point(inline.X + 4, (height - inline.Text.Height) * 0.5)); + } + else + { + context.DrawText(inline.Text, new Point(inline.X, (height - inline.Text.Height) * 0.5)); + } } } } From 832fcd7487c4ac384eaa09e50825487286b67bf5 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 8 May 2025 12:22:23 +0800 Subject: [PATCH 17/37] fix: offset of commit graph does not look quite right (#1287) This is because that when using `VirtualizingStackPanel`, the `Bounds.Height` of `ListBoxItem` may not be the same with its `Height` setted in axaml. Signed-off-by: leo --- src/Models/CommitGraph.cs | 4 +-- src/Views/CommitGraph.cs | 76 +++++++++++++++++++++++++-------------- src/Views/Histories.axaml | 2 +- 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/Models/CommitGraph.cs b/src/Models/CommitGraph.cs index 77209751..01488656 100644 --- a/src/Models/CommitGraph.cs +++ b/src/Models/CommitGraph.cs @@ -64,8 +64,8 @@ namespace SourceGit.Models { const double unitWidth = 12; const double halfWidth = 6; - const double unitHeight = 28; - const double halfHeight = 14; + const double unitHeight = 1; + const double halfHeight = 0.5; var temp = new CommitGraph(); var unsolved = new List(); diff --git a/src/Views/CommitGraph.cs b/src/Views/CommitGraph.cs index 015eaca5..faf883c6 100644 --- a/src/Views/CommitGraph.cs +++ b/src/Views/CommitGraph.cs @@ -56,22 +56,33 @@ namespace SourceGit.Views return; // Calculate drawing area. - double width = Bounds.Width - 273 - histories.AuthorNameColumnWidth.Value; - double height = Bounds.Height; - double startY = list.Scroll?.Offset.Y ?? 0; - double endY = startY + height + 28; + var width = Bounds.Width - 273 - histories.AuthorNameColumnWidth.Value; + var height = Bounds.Height; + + // Calculate row height + var container = list.ItemsPanelRoot as VirtualizingStackPanel; + if (container == null) + return; + + var item = list.ContainerFromIndex(container.FirstRealizedIndex); + if (item == null) + return; + + var rowHeight = item.Bounds.Height; + var startY = container.FirstRealizedIndex * rowHeight - item.TranslatePoint(new Point(0, 0), list).Value!.Y; + var endY = startY + height + 28; // Apply scroll offset and clip. using (context.PushClip(new Rect(0, 0, width, height))) using (context.PushTransform(Matrix.CreateTranslation(0, -startY))) { // Draw contents - DrawCurves(context, graph, startY, endY); - DrawAnchors(context, graph, startY, endY); + DrawCurves(context, graph, startY, endY, rowHeight); + DrawAnchors(context, graph, startY, endY, rowHeight); } } - private void DrawCurves(DrawingContext context, Models.CommitGraph graph, double top, double bottom) + private void DrawCurves(DrawingContext context, Models.CommitGraph graph, double top, double bottom, double rowHeight) { var grayedPen = new Pen(new SolidColorBrush(Colors.Gray, 0.4), Models.CommitGraph.Pens[0].Thickness); var onlyHighlightCurrentBranch = OnlyHighlightCurrentBranch; @@ -82,16 +93,20 @@ namespace SourceGit.Views { if (link.IsMerged) continue; - if (link.End.Y < top) + + var startY = link.Start.Y * rowHeight; + var endY = link.End.Y * rowHeight; + + if (endY < top) continue; - if (link.Start.Y > bottom) + if (startY > bottom) break; var geo = new StreamGeometry(); using (var ctx = geo.Open()) { - ctx.BeginFigure(link.Start, false); - ctx.QuadraticBezierTo(link.Control, link.End); + ctx.BeginFigure(new Point(link.Start.X, startY), false); + ctx.QuadraticBezierTo(new Point(link.Control.X, link.Control.Y * rowHeight), new Point(link.End.X, endY)); } context.DrawGeometry(null, grayedPen, geo); @@ -100,10 +115,11 @@ namespace SourceGit.Views foreach (var line in graph.Paths) { - var last = line.Points[0]; + var last = new Point(line.Points[0].X, line.Points[0].Y * rowHeight); var size = line.Points.Count; + var endY = line.Points[size - 1].Y * rowHeight; - if (line.Points[size - 1].Y < top) + if (endY < top) continue; if (last.Y > bottom) break; @@ -117,7 +133,7 @@ namespace SourceGit.Views var ended = false; for (int i = 1; i < size; i++) { - var cur = line.Points[i]; + var cur = new Point(line.Points[i].X, line.Points[i].Y * rowHeight); if (cur.Y < top) { last = cur; @@ -173,23 +189,27 @@ namespace SourceGit.Views { if (onlyHighlightCurrentBranch && !link.IsMerged) continue; - if (link.End.Y < top) + + var startY = link.Start.Y * rowHeight; + var endY = link.End.Y * rowHeight; + + if (endY < top) continue; - if (link.Start.Y > bottom) + if (startY > bottom) break; var geo = new StreamGeometry(); using (var ctx = geo.Open()) { - ctx.BeginFigure(link.Start, false); - ctx.QuadraticBezierTo(link.Control, link.End); + ctx.BeginFigure(new Point(link.Start.X, startY), false); + ctx.QuadraticBezierTo(new Point(link.Control.X, link.Control.Y * rowHeight), new Point(link.End.X, endY)); } context.DrawGeometry(null, Models.CommitGraph.Pens[link.Color], geo); } } - private void DrawAnchors(DrawingContext context, Models.CommitGraph graph, double top, double bottom) + private void DrawAnchors(DrawingContext context, Models.CommitGraph graph, double top, double bottom, double rowHeight) { var dotFill = DotBrush; var dotFillPen = new Pen(dotFill, 2); @@ -198,9 +218,11 @@ namespace SourceGit.Views foreach (var dot in graph.Dots) { - if (dot.Center.Y < top) + var center = new Point(dot.Center.X, dot.Center.Y * rowHeight); + + if (center.Y < top) continue; - if (dot.Center.Y > bottom) + if (center.Y > bottom) break; var pen = Models.CommitGraph.Pens[dot.Color]; @@ -210,16 +232,16 @@ namespace SourceGit.Views switch (dot.Type) { case Models.CommitGraph.DotType.Head: - context.DrawEllipse(dotFill, pen, dot.Center, 6, 6); - context.DrawEllipse(pen.Brush, null, dot.Center, 3, 3); + context.DrawEllipse(dotFill, pen, center, 6, 6); + context.DrawEllipse(pen.Brush, null, center, 3, 3); break; case Models.CommitGraph.DotType.Merge: - context.DrawEllipse(pen.Brush, null, dot.Center, 6, 6); - context.DrawLine(dotFillPen, new Point(dot.Center.X, dot.Center.Y - 3), new Point(dot.Center.X, dot.Center.Y + 3)); - context.DrawLine(dotFillPen, new Point(dot.Center.X - 3, dot.Center.Y), new Point(dot.Center.X + 3, dot.Center.Y)); + context.DrawEllipse(pen.Brush, null, center, 6, 6); + context.DrawLine(dotFillPen, new Point(center.X, center.Y - 3), new Point(center.X, center.Y + 3)); + context.DrawLine(dotFillPen, new Point(center.X - 3, center.Y), new Point(center.X + 3, center.Y)); break; default: - context.DrawEllipse(dotFill, pen, dot.Center, 3, 3); + context.DrawEllipse(dotFill, pen, center, 3, 3); break; } } diff --git a/src/Views/Histories.axaml b/src/Views/Histories.axaml index 86a96528..9b5e6514 100644 --- a/src/Views/Histories.axaml +++ b/src/Views/Histories.axaml @@ -76,7 +76,7 @@