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

Commit 1a8546e

Browse files
Merge pull request #232 from github-for-unity/fixes/history-view-repository-manager
Using Repository.Log from HistoryView
2 parents 7294e09 + db9ce8e commit 1a8546e

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

src/GitHub.Api/Git/IRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface IRepository : IEquatable<IRepository>
1111
void Initialize(IRepositoryManager repositoryManager);
1212
void Refresh();
1313
ITask SetupRemote(string remoteName, string remoteUrl);
14+
ITask<List<GitLogEntry>> Log();
1415
ITask Pull();
1516
ITask Push();
1617
ITask Fetch();

src/GitHub.Api/Git/Repository.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Globalization;
55
using System.Linq;
6+
using System.Threading;
67

78
namespace GitHub.Unity
89
{
@@ -78,6 +79,14 @@ public ITask SetupRemote(string remote, string remoteUrl)
7879
}
7980
}
8081

82+
public ITask<List<GitLogEntry>> Log()
83+
{
84+
if (repositoryManager == null)
85+
return new FuncListTask<GitLogEntry>(TaskHelpers.GetCompletedTask(new List<GitLogEntry>()));
86+
87+
return repositoryManager.Log();
88+
}
89+
8190
public ITask Pull()
8291
{
8392
return repositoryManager.Pull(CurrentRemote.Value.Name, CurrentBranch?.Name);

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface IRepositoryManager : IDisposable
2929
void Stop();
3030
void Refresh();
3131
ITask CommitFiles(List<string> files, string message, string body);
32+
ITask<List<GitLogEntry>> Log();
3233
ITask Fetch(string remote);
3334
ITask Pull(string remote, string branch);
3435
ITask Push(string remote, string branch);
@@ -200,6 +201,13 @@ public ITask CommitFiles(List<string> files, string message, string body)
200201
.Finally(() => IsBusy = false);
201202
}
202203

204+
public ITask<List<GitLogEntry>> Log()
205+
{
206+
var task = GitClient.Log();
207+
HookupHandlers(task);
208+
return task;
209+
}
210+
203211
public ITask Fetch(string remote)
204212
{
205213
var task = GitClient.Fetch(remote);

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<Compile Include="Helpers\Constants.cs" />
110110
<Compile Include="Cache\IBranchCache.cs" />
111111
<Compile Include="Helpers\Validation.cs" />
112+
<Compile Include="Helpers\TaskHelpers.cs" />
112113
<Compile Include="Platform\DefaultEnvironment.cs" />
113114
<Compile Include="Extensions\EnvironmentExtensions.cs" />
114115
<Compile Include="Extensions\FileEventExtensions.cs" />

src/GitHub.Api/Helpers/TaskHelpers.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Threading.Tasks;
2+
3+
namespace GitHub.Unity
4+
{
5+
static class TaskHelpers
6+
{
7+
public static Task<T> GetCompletedTask<T>(T result)
8+
{
9+
return TaskEx.FromResult(result);
10+
}
11+
}
12+
}

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,11 @@ private void UpdateStatus(GitStatus status)
203203

204204
private void RefreshLog()
205205
{
206-
if (GitClient != null)
206+
if (Repository != null)
207207
{
208-
if (Repository != null)
209-
{
210-
GitClient.Log().ThenInUI((success, log) => {
211-
if (success) OnLogUpdate(log);
212-
}).Start();
213-
}
208+
Repository.Log().ThenInUI((success, log) => {
209+
if (success) OnLogUpdate(log);
210+
}).Start();
214211
}
215212
}
216213

0 commit comments

Comments
 (0)