From b4fbc2372ba5c097ec611a33a4136ede8b438a79 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 10 Mar 2025 20:02:09 +0800 Subject: [PATCH] enhance: show commit info tip when hover SHA in conflict view Signed-off-by: leo --- src/ViewModels/Conflict.cs | 35 ++++++++-- src/Views/Conflict.axaml | 122 +++++++++++++++++++++++++++++++++ src/Views/Conflict.axaml.cs | 23 +++++++ src/Views/WorkingCopy.axaml | 79 +-------------------- src/Views/WorkingCopy.axaml.cs | 9 --- 5 files changed, 176 insertions(+), 92 deletions(-) create mode 100644 src/Views/Conflict.axaml create mode 100644 src/Views/Conflict.axaml.cs diff --git a/src/ViewModels/Conflict.cs b/src/ViewModels/Conflict.cs index 03c09e8a..1ccf4a33 100644 --- a/src/ViewModels/Conflict.cs +++ b/src/ViewModels/Conflict.cs @@ -1,5 +1,26 @@ namespace SourceGit.ViewModels { + public class ConflictSourceBranch + { + public string Name { get; private set; } + public string Head { get; private set; } + public Models.Commit Revision { get; private set; } + + public ConflictSourceBranch(string name, string head, Models.Commit revision) + { + Name = name; + Head = head; + Revision = revision; + } + + public ConflictSourceBranch(Repository repo, Models.Branch branch) + { + Name = branch.Name; + Head = branch.Head; + Revision = new Commands.QuerySingleCommit(repo.FullPath, branch.Head).Result() ?? new Models.Commit() { SHA = branch.Head }; + } + } + public class Conflict { public object Theirs @@ -31,28 +52,32 @@ if (context is CherryPickInProgress cherryPick) { Theirs = cherryPick.Head; - Mine = repo.CurrentBranch; + Mine = new ConflictSourceBranch(repo, repo.CurrentBranch); } else if (context is RebaseInProgress rebase) { var b = repo.Branches.Find(x => x.IsLocal && x.Name == rebase.HeadName); - Theirs = (object)b ?? rebase.StoppedAt; + if (b != null) + Theirs = new ConflictSourceBranch(b.Name, b.Head, rebase.StoppedAt); + else + Theirs = new ConflictSourceBranch(rebase.HeadName, rebase.StoppedAt?.SHA ?? "----------", rebase.StoppedAt); + Mine = rebase.Onto; } else if (context is RevertInProgress revert) { Theirs = revert.Head; - Mine = repo.CurrentBranch; + Mine = new ConflictSourceBranch(repo, repo.CurrentBranch); } else if (context is MergeInProgress merge) { Theirs = merge.Source; - Mine = repo.CurrentBranch; + Mine = new ConflictSourceBranch(repo, repo.CurrentBranch); } else { Theirs = "Stash or Patch"; - Mine = repo.CurrentBranch; + Mine = new ConflictSourceBranch(repo, repo.CurrentBranch); } } diff --git a/src/Views/Conflict.axaml b/src/Views/Conflict.axaml new file mode 100644 index 00000000..9a056f9e --- /dev/null +++ b/src/Views/Conflict.axaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +