mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
Making local detached branch HEAD as the first item below folders
This commit is contained in:
parent
4750ad0d07
commit
b0c00340a8
3 changed files with 21 additions and 7 deletions
|
@ -52,6 +52,11 @@ namespace SourceGit.Commands
|
||||||
if (refName.EndsWith("/HEAD", StringComparison.Ordinal))
|
if (refName.EndsWith("/HEAD", StringComparison.Ordinal))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (refName.StartsWith("(HEAD detached at"))
|
||||||
|
{
|
||||||
|
branch.isHead = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal))
|
if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
branch.Name = refName.Substring(PREFIX_LOCAL.Length);
|
branch.Name = refName.Substring(PREFIX_LOCAL.Length);
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
public string Upstream { get; set; }
|
public string Upstream { get; set; }
|
||||||
public string UpstreamTrackStatus { get; set; }
|
public string UpstreamTrackStatus { get; set; }
|
||||||
public string Remote { get; set; }
|
public string Remote { get; set; }
|
||||||
|
public bool isHead { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public enum BranchTreeNodeType
|
public enum BranchTreeNodeType
|
||||||
{
|
{
|
||||||
|
DetachedHead,
|
||||||
Remote,
|
Remote,
|
||||||
Folder,
|
Folder,
|
||||||
Branch,
|
Branch,
|
||||||
|
@ -46,6 +47,11 @@ namespace SourceGit.ViewModels
|
||||||
get => Type == BranchTreeNodeType.Branch;
|
get => Type == BranchTreeNodeType.Branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsDetachedHead
|
||||||
|
{
|
||||||
|
get => Type == BranchTreeNodeType.DetachedHead;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsCurrent
|
public bool IsCurrent
|
||||||
{
|
{
|
||||||
get => IsBranch && (Backend as Models.Branch).IsCurrent;
|
get => IsBranch && (Backend as Models.Branch).IsCurrent;
|
||||||
|
@ -174,7 +180,7 @@ namespace SourceGit.ViewModels
|
||||||
lastFolder.Children.Add(new BranchTreeNode()
|
lastFolder.Children.Add(new BranchTreeNode()
|
||||||
{
|
{
|
||||||
Name = Path.GetFileName(branch.Name),
|
Name = Path.GetFileName(branch.Name),
|
||||||
Type = BranchTreeNodeType.Branch,
|
Type = branch.isHead ? BranchTreeNodeType.DetachedHead : BranchTreeNodeType.Branch,
|
||||||
Backend = branch,
|
Backend = branch,
|
||||||
IsExpanded = false,
|
IsExpanded = false,
|
||||||
IsFiltered = isFiltered,
|
IsFiltered = isFiltered,
|
||||||
|
@ -185,14 +191,16 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
nodes.Sort((l, r) =>
|
nodes.Sort((l, r) =>
|
||||||
{
|
{
|
||||||
|
if (l.Type == BranchTreeNodeType.DetachedHead)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (l.Type == r.Type)
|
if (l.Type == r.Type)
|
||||||
{
|
{
|
||||||
return l.Name.CompareTo(r.Name);
|
return l.Name.CompareTo(r.Name);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return (int)l.Type - (int)r.Type;
|
return (int)l.Type - (int)r.Type;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var node in nodes)
|
foreach (var node in nodes)
|
||||||
|
|
Loading…
Reference in a new issue