enhance: show commit info tip when hover SHA in conflict view

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-03-10 20:02:09 +08:00
parent 2b2f070c4a
commit b4fbc2372b
No known key found for this signature in database
5 changed files with 176 additions and 92 deletions

View file

@ -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);
}
}