Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 36ba00a

Browse files
Rename Name to Path
1 parent 0a3ebd0 commit 36ba00a

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

src/GitHub.Api/Git/TreeData.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ namespace GitHub.Unity
44
{
55
public interface ITreeData
66
{
7-
string Name { get; }
7+
string FullPath { get; }
8+
string Path { get; }
89
bool IsActive { get; }
910
}
1011

@@ -20,7 +21,8 @@ public GitBranchTreeData(GitBranch gitBranch)
2021
GitBranch = gitBranch;
2122
}
2223

23-
public string Name => GitBranch.Name;
24+
public string FullPath => GitBranch.Name;
25+
public string Path => GitBranch.Name;
2426
public bool IsActive => GitBranch.IsActive;
2527
}
2628
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private void OnButtonBarGUI()
179179
{
180180
if (GUILayout.Button(DeleteBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
181181
{
182-
DeleteLocalBranch(treeLocals.SelectedNode.Name);
182+
DeleteLocalBranch(treeLocals.SelectedNode.Path);
183183
}
184184
}
185185
EditorGUI.EndDisabledGroup();
@@ -245,7 +245,7 @@ private void OnButtonBarGUI()
245245
// Effectuate create
246246
if (createBranch)
247247
{
248-
GitClient.CreateBranch(newBranchName, treeLocals.SelectedNode.Name)
248+
GitClient.CreateBranch(newBranchName, treeLocals.SelectedNode.Path)
249249
.FinallyInUI((success, e) =>
250250
{
251251
if (success)
@@ -299,7 +299,7 @@ private void OnTreeGUI(Rect rect)
299299
if (node.IsFolder)
300300
return;
301301

302-
SwitchBranch(node.Name);
302+
SwitchBranch(node.Path);
303303
},
304304
node => {
305305
if (node.IsFolder)
@@ -327,7 +327,7 @@ private void OnTreeGUI(Rect rect)
327327
if (node.IsFolder)
328328
return;
329329

330-
CheckoutRemoteBranch(node.Name);
330+
CheckoutRemoteBranch(node.Path);
331331
},
332332
node => {
333333
if (node.IsFolder)
@@ -364,11 +364,11 @@ private GenericMenu CreateContextMenuForLocalBranchNode(TreeNode node)
364364
else
365365
{
366366
genericMenu.AddItem(deleteGuiContent, false, () => {
367-
DeleteLocalBranch(node.Name);
367+
DeleteLocalBranch(node.Path);
368368
});
369369

370370
genericMenu.AddItem(switchGuiContent, false, () => {
371-
SwitchBranch(node.Name);
371+
SwitchBranch(node.Path);
372372
});
373373
}
374374

@@ -382,7 +382,7 @@ private GenericMenu CreateContextMenuForRemoteBranchNode(TreeNode node)
382382
var checkoutGuiContent = new GUIContent(CheckoutBranchContextMenuLabel);
383383

384384
genericMenu.AddItem(checkoutGuiContent, false, () => {
385-
CheckoutRemoteBranch(node.Name);
385+
CheckoutRemoteBranch(node.Path);
386386
});
387387

388388
return genericMenu;

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ public abstract class Tree
3535

3636
[NonSerialized] private Stack<bool> indents = new Stack<bool>();
3737

38-
public bool IsInitialized { get { return nodes != null && nodes.Count > 0 && !String.IsNullOrEmpty(nodes[0].Name); } }
38+
public bool IsInitialized { get { return nodes != null && nodes.Count > 0 && !String.IsNullOrEmpty(nodes[0].Path); } }
3939
public bool RequiresRepaint { get; private set; }
4040

4141
public TreeNode SelectedNode
4242
{
4343
get
4444
{
45-
if (selectedNode != null && String.IsNullOrEmpty(selectedNode.Name))
45+
if (selectedNode != null && String.IsNullOrEmpty(selectedNode.Path))
4646
selectedNode = null;
4747
return selectedNode;
4848
}
@@ -66,7 +66,7 @@ public void Load(IEnumerable<ITreeData> data, string title)
6666

6767
var titleNode = new TreeNode()
6868
{
69-
Name = title,
69+
Path = title,
7070
Label = title,
7171
Level = -1 + displayRootLevel,
7272
IsFolder = true,
@@ -80,29 +80,30 @@ public void Load(IEnumerable<ITreeData> data, string title)
8080

8181
foreach (var d in data)
8282
{
83-
var fullName = d.Name;
83+
var path = d.Path;
8484
if (PathIgnoreRoot != null)
8585
{
86-
var indexOf = fullName.IndexOf(PathIgnoreRoot);
86+
var indexOf = path.IndexOf(PathIgnoreRoot);
8787
if (indexOf != -1)
8888
{
89-
fullName = fullName.Substring(indexOf + PathIgnoreRoot.Length);
89+
path = path.Substring(indexOf + PathIgnoreRoot.Length);
9090
}
9191
}
9292

93-
var parts = fullName.Split(new [] {PathSeparator}, StringSplitOptions.None);
93+
var parts = path.Split(new [] {PathSeparator}, StringSplitOptions.None);
9494
for (int i = 0; i < parts.Length; i++)
9595
{
9696
var label = parts[i];
9797
var level = i + 1;
98-
var name = String.Join(PathSeparator, parts, 0, level);
98+
var nodePath = String.Join(PathSeparator, parts, 0, level);
9999
var isFolder = i < parts.Length - 1;
100-
var alreadyExists = folders.ContainsKey(name);
100+
var alreadyExists = folders.ContainsKey(nodePath);
101101
if (!alreadyExists)
102102
{
103103
var node = new TreeNode
104104
{
105-
Name = name,
105+
FullPath = d.FullPath,
106+
Path = nodePath,
106107
IsActive = d.IsActive,
107108
Label = label,
108109
Level = i + displayRootLevel,
@@ -132,7 +133,7 @@ public void Load(IEnumerable<ITreeData> data, string title)
132133
nodes.Add(node);
133134
if (isFolder)
134135
{
135-
if (collapsedFolders.Contains(name))
136+
if (collapsedFolders.Contains(nodePath))
136137
{
137138
node.IsCollapsed = true;
138139

@@ -143,7 +144,7 @@ public void Load(IEnumerable<ITreeData> data, string title)
143144
}
144145
}
145146

146-
folders.Add(name, node);
147+
folders.Add(nodePath, node);
147148
}
148149
}
149150
}
@@ -441,7 +442,8 @@ protected void LoadNodeIcons()
441442
[Serializable]
442443
public class TreeNode
443444
{
444-
public string Name;
445+
public string FullPath;
446+
public string Path;
445447
public string Label;
446448
public int Level;
447449
public bool IsFolder;
@@ -555,8 +557,8 @@ public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected
555557

556558
public override string ToString()
557559
{
558-
return String.Format("name:{0} label:{1} level:{2} isFolder:{3} isCollapsed:{4} isHidden:{5} isActive:{6}",
559-
Name, Label, Level, IsFolder, IsCollapsed, IsHidden, IsActive);
560+
return String.Format("path:{0} label:{1} level:{2} isFolder:{3} isCollapsed:{4} isHidden:{5} isActive:{6}",
561+
Path, Label, Level, IsFolder, IsCollapsed, IsHidden, IsActive);
560562
}
561563
}
562564

0 commit comments

Comments
 (0)