From 4750ad0d07311c45011af21972e9128b5a9940b3 Mon Sep 17 00:00:00 2001 From: Filipe Ramalho Date: Sat, 25 May 2024 15:05:32 -0300 Subject: [PATCH] Adding HEAD decorator markup in the Graph --- src/Commands/QueryCommits.cs | 9 +++++++++ src/Converters/DecoratorTypeConverters.cs | 5 ++++- src/Models/Commit.cs | 2 +- src/Models/Decorator.cs | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Commands/QueryCommits.cs b/src/Commands/QueryCommits.cs index 7d6ad169..618ff014 100644 --- a/src/Commands/QueryCommits.cs +++ b/src/Commands/QueryCommits.cs @@ -146,6 +146,15 @@ namespace SourceGit.Commands Name = d.Substring(19).Trim(), }); } + else if (d.Equals("HEAD")) + { + isHeadOfCurrent = true; + decorators.Add(new Models.Decorator() + { + Type = Models.DecoratorType.CurrentCommitHead, + Name = d.Trim(), + }); + } else if (d.StartsWith("refs/heads/", StringComparison.Ordinal)) { decorators.Add(new Models.Decorator() diff --git a/src/Converters/DecoratorTypeConverters.cs b/src/Converters/DecoratorTypeConverters.cs index eb016360..9f3d9447 100644 --- a/src/Converters/DecoratorTypeConverters.cs +++ b/src/Converters/DecoratorTypeConverters.cs @@ -38,6 +38,9 @@ namespace SourceGit.Converters }); public static readonly FuncValueConverter ToFontWeight = - new FuncValueConverter(v => v == Models.DecoratorType.CurrentBranchHead ? FontWeight.Bold : FontWeight.Regular); + new FuncValueConverter(v => + v is Models.DecoratorType.CurrentBranchHead or Models.DecoratorType.CurrentCommitHead + ? FontWeight.Bold : FontWeight.Regular + ); } } diff --git a/src/Models/Commit.cs b/src/Models/Commit.cs index 4b3f0ed3..d8355e81 100644 --- a/src/Models/Commit.cs +++ b/src/Models/Commit.cs @@ -32,7 +32,7 @@ namespace SourceGit.Models public bool IsCurrentHead { - get => Decorators.Find(x => x.Type == DecoratorType.CurrentBranchHead) != null; + get => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null; } public string FullMessage diff --git a/src/Models/Decorator.cs b/src/Models/Decorator.cs index 10967b45..60ffc1ee 100644 --- a/src/Models/Decorator.cs +++ b/src/Models/Decorator.cs @@ -7,6 +7,7 @@ namespace SourceGit.Models None, CurrentBranchHead, LocalBranchHead, + CurrentCommitHead, RemoteBranchHead, Tag, }