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

Commit 02b2b9e

Browse files
committed
Throw if the manager isn't ready so that windows use their cached data instead
1 parent a88a5f3 commit 02b2b9e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/GitHub.Api/Git/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public ITask SetupRemote(string remote, string remoteUrl)
8282
public ITask<List<GitLogEntry>> Log()
8383
{
8484
if (repositoryManager == null)
85-
return new FuncListTask<GitLogEntry>(TaskHelpers.GetCompletedTask(new List<GitLogEntry>()));
85+
return new FuncListTask<GitLogEntry>(new NotReadyException().ToTask<List<GitLogEntry>>());
8686

8787
return repositoryManager.Log();
8888
}

src/GitHub.Api/Helpers/TaskHelpers.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Threading.Tasks;
23

34
namespace GitHub.Unity
@@ -8,5 +9,16 @@ public static Task<T> GetCompletedTask<T>(T result)
89
{
910
return TaskEx.FromResult(result);
1011
}
12+
13+
public static Task<T> ToTask<T>(this Exception exception)
14+
{
15+
TaskCompletionSource<T> completionSource = new TaskCompletionSource<T>();
16+
completionSource.TrySetException(exception);
17+
return completionSource.Task;
18+
}
19+
}
20+
21+
public class NotReadyException : Exception
22+
{
1123
}
1224
}

0 commit comments

Comments
 (0)