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

Commit 01870e0

Browse files
Merge branch 'master' into fixes/cleanup
2 parents adf0d22 + 75989da commit 01870e0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/GitHub.Api/Git/Repository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public ITask SetupRemote(string remote, string remoteUrl)
8585
public ITask<List<GitLogEntry>> Log()
8686
{
8787
if (repositoryManager == null)
88-
return new FuncListTask<GitLogEntry>(TaskHelpers.GetCompletedTask(new List<GitLogEntry>()));
88+
return new FuncListTask<GitLogEntry>(new NotReadyException().ToTask<List<GitLogEntry>>());
8989

9090
return repositoryManager.Log();
9191
}
@@ -123,7 +123,7 @@ public ITask Revert(string changeset)
123123
public ITask ListLocks()
124124
{
125125
if (repositoryManager == null)
126-
return new ActionTask(TaskExtensions.CompletedTask);
126+
return new ActionTask(new NotReadyException().ToTask<bool>());
127127
return repositoryManager.ListLocks(false);
128128
}
129129

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)