Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/GitHub.Api/Git/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public ITask SetupRemote(string remote, string remoteUrl)
public ITask<List<GitLogEntry>> Log()
{
if (repositoryManager == null)
return new FuncListTask<GitLogEntry>(TaskHelpers.GetCompletedTask(new List<GitLogEntry>()));
return new FuncListTask<GitLogEntry>(new NotReadyException().ToTask<List<GitLogEntry>>());

return repositoryManager.Log();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ public ITask Revert(string changeset)
public ITask ListLocks()
{
if (repositoryManager == null)
return new ActionTask(TaskExtensions.CompletedTask);
return new ActionTask(new NotReadyException().ToTask<bool>());
return repositoryManager.ListLocks(false);
}

Expand Down
12 changes: 12 additions & 0 deletions src/GitHub.Api/Helpers/TaskHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;

namespace GitHub.Unity
Expand All @@ -8,5 +9,16 @@ public static Task<T> GetCompletedTask<T>(T result)
{
return TaskEx.FromResult(result);
}

public static Task<T> ToTask<T>(this Exception exception)
{
TaskCompletionSource<T> completionSource = new TaskCompletionSource<T>();
completionSource.TrySetException(exception);
return completionSource.Task;
}
}

public class NotReadyException : Exception
{
}
}