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

Commit 0a3ebd0

Browse files
Separating GitBranch from ITreeData
1 parent 656007e commit 0a3ebd0

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

src/GitHub.Api/Git/GitBranch.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22

33
namespace GitHub.Unity
44
{
5-
public interface ITreeData
6-
{
7-
string Name { get; }
8-
bool IsActive { get; }
9-
}
10-
115
[Serializable]
12-
public struct GitBranch : ITreeData
6+
public struct GitBranch
137
{
148
public static GitBranch Default = new GitBranch();
159

src/GitHub.Api/Git/TreeData.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
3+
namespace GitHub.Unity
4+
{
5+
public interface ITreeData
6+
{
7+
string Name { get; }
8+
bool IsActive { get; }
9+
}
10+
11+
[Serializable]
12+
public struct GitBranchTreeData : ITreeData
13+
{
14+
public static GitBranchTreeData Default = new GitBranchTreeData(Unity.GitBranch.Default);
15+
16+
public GitBranch GitBranch;
17+
18+
public GitBranchTreeData(GitBranch gitBranch)
19+
{
20+
GitBranch = gitBranch;
21+
}
22+
23+
public string Name => GitBranch.Name;
24+
public bool IsActive => GitBranch.IsActive;
25+
}
26+
}

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<Compile Include="Git\ManagedCacheExtensions.cs" />
107107
<Compile Include="Git\Tasks\GitLfsVersionTask.cs" />
108108
<Compile Include="Git\Tasks\GitVersionTask.cs" />
109+
<Compile Include="Git\TreeData.cs" />
109110
<Compile Include="Git\ValidateGitInstallResult.cs" />
110111
<Compile Include="Helpers\AssemblyResources.cs" />
111112
<Compile Include="Authentication\IKeychain.cs" />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ private void BuildTree()
151151
localBranches.Sort(CompareBranches);
152152
remoteBranches.Sort(CompareBranches);
153153

154-
treeLocals.Load(localBranches.Cast<ITreeData>(), LocalTitle);
155-
treeRemotes.Load(remoteBranches.Cast<ITreeData>(), RemoteTitle);
154+
treeLocals.Load(localBranches.Select(branch => (ITreeData) new GitBranchTreeData(branch)), LocalTitle);
155+
treeRemotes.Load(remoteBranches.Select(branch => (ITreeData) new GitBranchTreeData(branch)), RemoteTitle);
156156
Redraw();
157157
}
158158

0 commit comments

Comments
 (0)