mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07: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
|
@ -51,7 +51,12 @@ namespace SourceGit.Commands
|
||||||
var refName = parts[0];
|
var refName = parts[0];
|
||||||
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,
|
||||||
|
@ -45,6 +46,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
|
||||||
{
|
{
|
||||||
|
@ -170,11 +176,11 @@ namespace SourceGit.ViewModels
|
||||||
start = sepIdx + 1;
|
start = sepIdx + 1;
|
||||||
sepIdx = branch.Name.IndexOf('/', start);
|
sepIdx = branch.Name.IndexOf('/', start);
|
||||||
}
|
}
|
||||||
|
|
||||||
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