-
Notifications
You must be signed in to change notification settings - Fork 386
Expand file tree
/
Copy pathBranch.cs
More file actions
44 lines (39 loc) · 1.38 KB
/
Branch.cs
File metadata and controls
44 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections.Generic;
namespace SourceGit.Models
{
public enum BranchSortMode
{
Name = 0,
CommitterDate,
}
public class Branch
{
public string Name { get; set; }
public string FullName { get; set; }
public ulong CommitterDate { get; set; }
public string Head { get; set; }
public bool IsLocal { get; set; }
public bool IsCurrent { get; set; }
public bool IsDetachedHead { get; set; }
public string Upstream { get; set; }
public List<string> Ahead { get; set; } = [];
public List<string> Behind { get; set; } = [];
public string Remote { get; set; }
public bool IsUpstreamGone { get; set; }
public string WorktreePath { get; set; }
public bool HasWorktree => !IsCurrent && !string.IsNullOrEmpty(WorktreePath);
public string FriendlyName => IsLocal ? Name : $"{Remote}/{Name}";
public bool IsTrackStatusVisible => Ahead.Count > 0 || Behind.Count > 0;
public string TrackStatusDescription
{
get
{
var ahead = Ahead.Count;
var behind = Behind.Count;
if (ahead > 0)
return behind > 0 ? $"{ahead}↑ {behind}↓" : $"{ahead}↑";
return behind > 0 ? $"{behind}↓" : string.Empty;
}
}
}
}