sourcegit/src/Models/Worktree.cs
Dmitrij D. Czarkoff 588879eb7f
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.
2025-02-13 10:41:08 +08:00

39 lines
1.1 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.Models
{
public class Worktree : ObservableObject
{
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;
public bool IsLocked
{
get => _isLocked;
set => SetProperty(ref _isLocked, value);
}
public string Name
{
get
{
if (IsDetached)
return $"deteched HEAD at {Head.Substring(10)}";
if (Branch.StartsWith("refs/heads/", System.StringComparison.Ordinal))
return Branch.Substring(11);
if (Branch.StartsWith("refs/remotes/", System.StringComparison.Ordinal))
return Branch.Substring(13);
return Branch;
}
}
private bool _isLocked = false;
}
}