feat: change worktree presentation (#978)

Present the worktree name first, then relative path to the main repo.

This is more aligned with Git's own UI,  and works better with UI size constrains.
This commit is contained in:
Dmitrij D. Czarkoff 2025-02-13 02:41:08 +00:00 committed by GitHub
parent c6aedf1193
commit 588879eb7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 8 deletions

View file

@ -6,6 +6,7 @@ namespace SourceGit.Models
{
public string Branch { get; set; } = string.Empty;
public string FullPath { get; set; } = string.Empty;
public string RelativePath { get; set; } = string.Empty;
public string Head { get; set; } = string.Empty;
public bool IsBare { get; set; } = false;
public bool IsDetached { get; set; } = false;
@ -21,15 +22,15 @@ namespace SourceGit.Models
get
{
if (IsDetached)
return $"(deteched HEAD at {Head.Substring(10)})";
return $"deteched HEAD at {Head.Substring(10)}";
if (Branch.StartsWith("refs/heads/", System.StringComparison.Ordinal))
return $"({Branch.Substring(11)})";
return Branch.Substring(11);
if (Branch.StartsWith("refs/remotes/", System.StringComparison.Ordinal))
return $"({Branch.Substring(13)})";
return Branch.Substring(13);
return $"({Branch})";
return Branch;
}
}