From c611b62992d5a3f167998c9141afac438d85d2e4 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sun, 10 Nov 2024 17:45:26 +0100 Subject: [PATCH 1/7] feature: add children list to the commit base info view Useful for navigation between the commits. --- src/Commands/QueryCommitChildren.cs | 31 +++++++++++++++++ src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/fr_FR.axaml | 1 + src/ViewModels/CommitDetail.cs | 13 +++++++ src/Views/CommitBaseInfo.axaml | 53 ++++++++++++++++++++++++++--- src/Views/CommitBaseInfo.axaml.cs | 9 +++++ src/Views/CommitDetail.axaml | 1 + 7 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 src/Commands/QueryCommitChildren.cs diff --git a/src/Commands/QueryCommitChildren.cs b/src/Commands/QueryCommitChildren.cs new file mode 100644 index 00000000..ec6057a3 --- /dev/null +++ b/src/Commands/QueryCommitChildren.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace SourceGit.Commands +{ + public class QueryCommitChildren : Command + { + public QueryCommitChildren(string repo, string commit) + { + WorkingDirectory = repo; + Context = repo; + _commit = commit; + Args = $"rev-list --parents --all ^{commit}"; + } + + public IEnumerable Result() + { + var rs = ReadToEnd(); + if (!rs.IsSuccess) + yield break; + + foreach (string s in rs.StdOut.Split('\n', StringSplitOptions.None)) + { + if (s.Contains(_commit)) + yield return s.Substring(0, 40); + } + } + + private string _commit; + } +} diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index ed4f1baf..cb0bf568 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -125,6 +125,7 @@ INFORMATION AUTHOR CHANGED + CHILDREN COMMITTER Check refs that contains this commit COMMIT IS CONTAINED BY diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 75cd4d58..5a1a8e7b 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -126,6 +126,7 @@ INFORMATIONS AUTEUR CHANGÉ + ENFANTS COMMITTER Vérifier les références contenant ce commit LE COMMIT EST CONTENU PAR diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 7ef8ce85..1d9495e4 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -78,6 +78,12 @@ namespace SourceGit.ViewModels } } + public AvaloniaList Children + { + get; + private set; + } = new AvaloniaList(); + public string SearchChangeFilter { get => _searchChangeFilter; @@ -515,6 +521,7 @@ namespace SourceGit.ViewModels VisibleChanges = null; SelectedChanges = null; ViewRevisionFileContent = null; + Children.Clear(); if (_commit == null) return; @@ -531,6 +538,12 @@ namespace SourceGit.ViewModels Dispatcher.UIThread.Invoke(() => SignInfo = signInfo); }); + Task.Run(() => + { + var children = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA).Result(); + Dispatcher.UIThread.Invoke(() => Children.AddRange(children)); + }); + if (_cancelToken != null) _cancelToken.Requested = true; diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index d8b77a18..aeff355b 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -51,7 +51,7 @@ - + @@ -143,9 +143,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + SetValue(IssueTrackerRulesProperty, value); } + public static readonly StyledProperty> ChildrenProperty = + AvaloniaProperty.Register>(nameof(Children)); + + public AvaloniaList Children + { + get => GetValue(ChildrenProperty); + set => SetValue(ChildrenProperty, value); + } + public CommitBaseInfo() { InitializeComponent(); diff --git a/src/Views/CommitDetail.axaml b/src/Views/CommitDetail.axaml index cb99b3d9..4c6fd5dc 100644 --- a/src/Views/CommitDetail.axaml +++ b/src/Views/CommitDetail.axaml @@ -24,6 +24,7 @@ SignInfo="{Binding SignInfo}" SupportsContainsIn="True" WebLinks="{Binding WebLinks}" + Children="{Binding Children}" IssueTrackerRules="{Binding IssueTrackerRules}"/> From 3fb1c763f3c98e0baa80534e5698d0fd945c1e85 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sat, 16 Nov 2024 21:26:03 +0100 Subject: [PATCH 2/7] feature: use repository filters to limit children search --- src/Commands/QueryCommitChildren.cs | 6 ++++-- src/ViewModels/CommitDetail.cs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Commands/QueryCommitChildren.cs b/src/Commands/QueryCommitChildren.cs index ec6057a3..bcf63fa5 100644 --- a/src/Commands/QueryCommitChildren.cs +++ b/src/Commands/QueryCommitChildren.cs @@ -5,12 +5,14 @@ namespace SourceGit.Commands { public class QueryCommitChildren : Command { - public QueryCommitChildren(string repo, string commit) + public QueryCommitChildren(string repo, string commit, string filters) { WorkingDirectory = repo; Context = repo; _commit = commit; - Args = $"rev-list --parents --all ^{commit}"; + if (string.IsNullOrEmpty(filters)) + filters = "--all"; + Args = $"rev-list --parents {filters} ^{commit}"; } public IEnumerable Result() diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 1d9495e4..f54ae5cb 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -540,7 +540,7 @@ namespace SourceGit.ViewModels Task.Run(() => { - var children = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA).Result(); + var children = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, _repo.Settings.BuildHistoriesFilter()).Result(); Dispatcher.UIThread.Invoke(() => Children.AddRange(children)); }); From f96f6024566f8ed7c620f7fb82da234c28f6b628 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sun, 17 Nov 2024 01:31:25 +0100 Subject: [PATCH 3/7] feature: execute children search asynchronously --- src/Commands/QueryCommitChildren.cs | 18 +++++++++--------- src/ViewModels/CommitDetail.cs | 15 +++++++++------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Commands/QueryCommitChildren.cs b/src/Commands/QueryCommitChildren.cs index bcf63fa5..2b8fd9f1 100644 --- a/src/Commands/QueryCommitChildren.cs +++ b/src/Commands/QueryCommitChildren.cs @@ -15,19 +15,19 @@ namespace SourceGit.Commands Args = $"rev-list --parents {filters} ^{commit}"; } + protected override void OnReadline(string line) + { + if (line.Contains(_commit)) + _lines.Add(line); + } + public IEnumerable Result() { - var rs = ReadToEnd(); - if (!rs.IsSuccess) - yield break; - - foreach (string s in rs.StdOut.Split('\n', StringSplitOptions.None)) - { - if (s.Contains(_commit)) - yield return s.Substring(0, 40); - } + Exec(); + return _lines; } private string _commit; + private List _lines = new List(); } } diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index f54ae5cb..a816d48a 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -538,16 +538,19 @@ namespace SourceGit.ViewModels Dispatcher.UIThread.Invoke(() => SignInfo = signInfo); }); - Task.Run(() => - { - var children = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, _repo.Settings.BuildHistoriesFilter()).Result(); - Dispatcher.UIThread.Invoke(() => Children.AddRange(children)); - }); - if (_cancelToken != null) _cancelToken.Requested = true; _cancelToken = new Commands.Command.CancelToken(); + + Task.Run(() => + { + var cmdChildren = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, _repo.Settings.BuildHistoriesFilter()) { Cancel = _cancelToken }; + var children = cmdChildren.Result(); + if (!cmdChildren.Cancel.Requested) + Dispatcher.UIThread.Post(() => Children.AddRange(children)); + }); + Task.Run(() => { var parent = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0]; From 88fb754415aebce31eb4eb650d75bfea7f4658d4 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sun, 17 Nov 2024 02:04:22 +0100 Subject: [PATCH 4/7] feature: respect global commit limit for a good measure --- src/Commands/QueryCommitChildren.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/QueryCommitChildren.cs b/src/Commands/QueryCommitChildren.cs index 2b8fd9f1..e6c76a99 100644 --- a/src/Commands/QueryCommitChildren.cs +++ b/src/Commands/QueryCommitChildren.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using SourceGit.ViewModels; namespace SourceGit.Commands { @@ -12,7 +13,7 @@ namespace SourceGit.Commands _commit = commit; if (string.IsNullOrEmpty(filters)) filters = "--all"; - Args = $"rev-list --parents {filters} ^{commit}"; + Args = $"rev-list -{Preference.Instance.MaxHistoryCommits} --parents {filters} ^{commit}"; } protected override void OnReadline(string line) From f3c9690d474f5efaefa82cf17116a1ca565e642e Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 19 Nov 2024 18:38:36 +0100 Subject: [PATCH 5/7] fix: input lines may contain several commits The first commit is always the immediate child, so take only 40 initial characters of the line --- src/Commands/QueryCommitChildren.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/QueryCommitChildren.cs b/src/Commands/QueryCommitChildren.cs index e6c76a99..c110ef94 100644 --- a/src/Commands/QueryCommitChildren.cs +++ b/src/Commands/QueryCommitChildren.cs @@ -19,7 +19,7 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { if (line.Contains(_commit)) - _lines.Add(line); + _lines.Add(line.Substring(0, 40)); } public IEnumerable Result() From e8c8ac55a14c73faf1bfce5dd74cf54911263124 Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 19 Nov 2024 19:01:09 +0100 Subject: [PATCH 6/7] fix: hide children behind the preference --- src/Resources/Locales/en_US.axaml | 1 + src/ViewModels/CommitDetail.cs | 15 +++++++++------ src/ViewModels/Preference.cs | 8 ++++++++ src/Views/Preference.axaml | 9 +++++++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index cb0bf568..462cdf90 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -452,6 +452,7 @@ Language History Commits Show author time intead of commit time in graph + Show children in the comment details Subject Guide Length GIT Enable Auto CRLF diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index a816d48a..6d819300 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -543,13 +543,16 @@ namespace SourceGit.ViewModels _cancelToken = new Commands.Command.CancelToken(); - Task.Run(() => + if (Preference.Instance.ShowChildren) { - var cmdChildren = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, _repo.Settings.BuildHistoriesFilter()) { Cancel = _cancelToken }; - var children = cmdChildren.Result(); - if (!cmdChildren.Cancel.Requested) - Dispatcher.UIThread.Post(() => Children.AddRange(children)); - }); + Task.Run(() => + { + var cmdChildren = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA, _repo.Settings.BuildHistoriesFilter()) { Cancel = _cancelToken }; + var children = cmdChildren.Result(); + if (!cmdChildren.Cancel.Requested) + Dispatcher.UIThread.Post(() => Children.AddRange(children)); + }); + } Task.Run(() => { diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index 68065df1..9d3de526 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -294,6 +294,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _statisticsSampleColor, value); } + public bool ShowChildren + { + get => _showChildren; + set => SetProperty(ref _showChildren, value); + } + public List RepositoryNodes { get; @@ -617,5 +623,7 @@ namespace SourceGit.ViewModels private string _externalMergeToolPath = string.Empty; private uint _statisticsSampleColor = 0xFF00FF00; + + private bool _showChildren = false; } } diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 9b84604a..0c7986ab 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -45,7 +45,7 @@ - + + + @@ -188,7 +193,7 @@ - + Date: Tue, 19 Nov 2024 19:13:34 +0100 Subject: [PATCH 7/7] feature: make parents and children scrollable --- src/Views/CommitBaseInfo.axaml | 152 +++++++++++++++++---------------- 1 file changed, 78 insertions(+), 74 deletions(-) diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index aeff355b..d3d3bb0e 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -102,89 +102,93 @@ - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + + - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + +