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

Commit 5f011ad

Browse files
Merge branch 'enhancements/tree-improvements' into enhancements/changes-tree-view
# Conflicts: # src/GitHub.Api/UI/TreeLoader.cs # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs
2 parents 3e4f470 + c42a78d commit 5f011ad

18 files changed

+406
-225
lines changed

src/GitHub.Api/Cache/CacheInterfaces.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ public enum CacheType
88
RepositoryInfoCache,
99
BranchCache,
1010
GitLogCache,
11-
GitStatusCache,
11+
GitTrackingStatusCache,
12+
GitStatusEntriesCache,
1213
GitLocksCache,
1314
GitUserCache
1415
}
@@ -20,7 +21,8 @@ public interface ICacheContainer
2021

2122
IBranchCache BranchCache { get; }
2223
IGitLogCache GitLogCache { get; }
23-
IGitStatusCache GitStatusCache { get; }
24+
IGitTrackingStatusCache GitTrackingStatusCache { get; }
25+
IGitStatusEntriesCache GitStatusEntriesCache { get; }
2426
IGitLocksCache GitLocksCache { get; }
2527
IGitUserCache GitUserCache { get; }
2628
IRepositoryInfoCache RepositoryInfoCache { get; }
@@ -53,10 +55,14 @@ public interface IGitUserCache : IManagedCache
5355
string Email { get; set; }
5456
}
5557

56-
public interface IGitStatusCache : IManagedCache
58+
public interface IGitTrackingStatusCache : IManagedCache
5759
{
5860
int Ahead { get; set; }
5961
int Behind { get; set; }
62+
}
63+
64+
public interface IGitStatusEntriesCache : IManagedCache
65+
{
6066
List<GitStatusEntry> Entries { get; set; }
6167
}
6268

src/GitHub.Api/Git/GitConfig.cs

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,56 @@ namespace GitHub.Unity
99
[Serializable]
1010
public struct ConfigRemote
1111
{
12-
public string Name;
13-
public string Url;
12+
public static ConfigRemote Default = new ConfigRemote(String.Empty, String.Empty);
13+
14+
public string name;
15+
public string url;
16+
17+
public ConfigRemote(string name, string url)
18+
{
19+
this.name = name;
20+
this.url = url;
21+
}
22+
23+
public string Name => name;
24+
25+
public string Url => url;
1426

1527
public override string ToString()
1628
{
17-
return String.Format("{{Remote {0} {1}}}", Name, Url);
29+
return $"{{Remote {Name} {Url}}}";
1830
}
1931
}
2032

2133
[Serializable]
2234
public struct ConfigBranch
2335
{
24-
public string Name;
25-
public ConfigRemote? Remote;
36+
public static ConfigBranch Default = new ConfigBranch(String.Empty);
37+
38+
public string name;
39+
public ConfigRemote remote;
40+
41+
public ConfigBranch(string name)
42+
{
43+
this.name = name;
44+
remote = ConfigRemote.Default;
45+
}
46+
47+
public ConfigBranch(string name, ConfigRemote? remote)
48+
{
49+
this.name = name;
50+
this.remote = remote ?? ConfigRemote.Default;
51+
}
52+
2653
public bool IsTracking => Remote.HasValue;
2754

55+
public string Name => name;
56+
57+
public ConfigRemote? Remote => Equals(remote, ConfigRemote.Default) ? (ConfigRemote?) null : remote;
58+
2859
public override string ToString()
2960
{
30-
return String.Format("{{Branch {0} {1}}}", Name, Remote?.ToString() ?? "Untracked");
61+
return $"{{Branch {Name} {Remote?.ToString() ?? "Untracked"}}}";
3162
}
3263
}
3364

@@ -74,11 +105,7 @@ public IEnumerable<ConfigBranch> GetBranches()
74105
return groups
75106
.Where(x => x.Key == "branch")
76107
.SelectMany(x => x.Value)
77-
.Select(x => new ConfigBranch
78-
{
79-
Name = x.Key,
80-
Remote = GetRemote(x.Value.TryGetString("remote"))
81-
});
108+
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote"))));
82109
}
83110

84111
public IEnumerable<ConfigRemote> GetRemotes()
@@ -87,11 +114,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
87114
.Where(x => x.Key == "remote")
88115
.SelectMany(x => x.Value)
89116
.Where(x => x.Value.TryGetString("url") != null)
90-
.Select(x => new ConfigRemote
91-
{
92-
Name = x.Key,
93-
Url = x.Value.TryGetString("url")
94-
});
117+
.Select(x => new ConfigRemote(x.Key, x.Value.TryGetString("url")));
95118
}
96119

97120
public ConfigRemote? GetRemote(string remote)
@@ -100,11 +123,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
100123
.Where(x => x.Key == "remote")
101124
.SelectMany(x => x.Value)
102125
.Where(x => x.Key == remote && x.Value.TryGetString("url") != null)
103-
.Select(x => new ConfigRemote
104-
{
105-
Name = x.Key,
106-
Url = x.Value.GetString("url")
107-
} as ConfigRemote?)
126+
.Select(x => new ConfigRemote(x.Key,x.Value.GetString("url")) as ConfigRemote?)
108127
.FirstOrDefault();
109128
}
110129

@@ -114,11 +133,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
114133
.Where(x => x.Key == "branch")
115134
.SelectMany(x => x.Value)
116135
.Where(x => x.Key == branch)
117-
.Select(x => new ConfigBranch
118-
{
119-
Name = x.Key,
120-
Remote = GetRemote(x.Value.TryGetString("remote"))
121-
} as ConfigBranch?)
136+
.Select(x => new ConfigBranch(x.Key,GetRemote(x.Value.TryGetString("remote"))) as ConfigBranch?)
122137
.FirstOrDefault();
123138
}
124139

src/GitHub.Api/Git/IRepository.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface IRepository : IEquatable<IRepository>
2121

2222
void CheckLogChangedEvent(CacheUpdateEvent gitLogCacheUpdateEvent);
2323
void CheckStatusChangedEvent(CacheUpdateEvent cacheUpdateEvent);
24+
void CheckStatusEntriesChangedEvent(CacheUpdateEvent cacheUpdateEvent);
2425
void CheckCurrentBranchChangedEvent(CacheUpdateEvent cacheUpdateEvent);
2526
void CheckCurrentRemoteChangedEvent(CacheUpdateEvent cacheUpdateEvent);
2627
void CheckCurrentBranchAndRemoteChangedEvent(CacheUpdateEvent cacheUpdateEvent);
@@ -68,7 +69,8 @@ public interface IRepository : IEquatable<IRepository>
6869
List<GitLogEntry> CurrentLog { get; }
6970

7071
event Action<CacheUpdateEvent> LogChanged;
71-
event Action<CacheUpdateEvent> StatusChanged;
72+
event Action<CacheUpdateEvent> TrackingStatusChanged;
73+
event Action<CacheUpdateEvent> StatusEntriesChanged;
7274
event Action<CacheUpdateEvent> CurrentBranchChanged;
7375
event Action<CacheUpdateEvent> CurrentRemoteChanged;
7476
event Action<CacheUpdateEvent> CurrentBranchAndRemoteChanged;

src/GitHub.Api/Git/ManagedCacheExtensions.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)