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

Commit b45a0f9

Browse files
Removing a lot more octokit
1 parent be899c4 commit b45a0f9

File tree

9 files changed

+5
-72
lines changed

9 files changed

+5
-72
lines changed

src/GitHub.Api/Application/ApplicationConfiguration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using Octokit;
32

43
namespace GitHub.Unity
54
{

src/GitHub.Api/Application/OctokitExtensions.cs

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

src/GitHub.Api/Authentication/ILoginManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Threading.Tasks;
2-
using Octokit;
32

43
namespace GitHub.Unity
54
{

src/GitHub.Api/Authentication/Keychain.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
5-
using Octokit;
65
using GitHub.Logging;
76

87
namespace GitHub.Unity
@@ -220,7 +219,7 @@ public async Task Save(UriString host)
220219
throw new ArgumentException($"Host: {host} is not found");
221220
}
222221

223-
if (credentialAdapter.OctokitCredentials == Credentials.Anonymous)
222+
if (string.IsNullOrEmpty(credentialAdapter.Credential.Token))
224223
{
225224
throw new InvalidOperationException("Anonymous credentials cannot be stored");
226225
}
@@ -229,7 +228,7 @@ public async Task Save(UriString host)
229228
if (connectionCache.ContainsKey(host))
230229
connectionCache.Remove(host);
231230

232-
connectionCache.Add(host, new Connection { Host = host, Username = credentialAdapter.OctokitCredentials.Login });
231+
connectionCache.Add(host, new Connection { Host = host, Username = credentialAdapter.Credential.Username });
233232

234233
// flushes credential cache to disk (host and username only)
235234
WriteCacheToDisk();
@@ -275,6 +274,6 @@ public void UpdateToken(UriString host, string token)
275274

276275
public bool HasKeys => connectionCache.Any();
277276

278-
public bool NeedsLoad => HasKeys && FindOrCreateAdapter(connectionCache.First().Value.Host).OctokitCredentials == Credentials.Anonymous;
277+
public bool NeedsLoad => HasKeys && FindOrCreateAdapter(connectionCache.First().Value.Host).Credential.Token != null;
279278
}
280279
}
Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,27 @@
1-
using System.Threading.Tasks;
2-
using Octokit;
3-
4-
namespace GitHub.Unity
1+
namespace GitHub.Unity
52
{
63
class KeychainAdapter : IKeychainAdapter
74
{
8-
public Credentials OctokitCredentials { get; private set; } = Credentials.Anonymous;
95
public ICredential Credential { get; private set; }
106

117
public void Set(ICredential credential)
128
{
139
Credential = credential;
14-
OctokitCredentials = new Credentials(credential.Username, credential.Token);
1510
}
1611

1712
public void UpdateToken(string token)
1813
{
1914
Credential.UpdateToken(token);
20-
OctokitCredentials = new Credentials(OctokitCredentials.Login, token);
2115
}
2216

2317
public void Clear()
2418
{
25-
OctokitCredentials = Credentials.Anonymous;
2619
Credential = null;
2720
}
28-
29-
/// <summary>
30-
/// Implementation for Octokit
31-
/// </summary>
32-
/// <returns>Octokit credentials</returns>
33-
Task<Credentials> ICredentialStore.GetCredentials()
34-
{
35-
return TaskEx.FromResult(OctokitCredentials);
36-
}
3721
}
3822

39-
public interface IKeychainAdapter: ICredentialStore
23+
public interface IKeychainAdapter
4024
{
41-
Credentials OctokitCredentials { get; }
4225
ICredential Credential { get; }
4326
}
4427
}

src/GitHub.Api/Authentication/LoginManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Net;
33
using System.Threading.Tasks;
4-
using Octokit;
54
using GitHub.Logging;
65

76
namespace GitHub.Unity

src/GitHub.Api/Extensions/ExceptionExtensions.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
using System;
2-
using System.Linq;
3-
using Octokit;
42
using System.Threading;
53

64
namespace GitHub.Unity
75
{
8-
static class ApiExceptionExtensions
9-
{
10-
const string GithubHeader = "X-GitHub-Request-Id";
11-
public static bool IsGitHubApiException(this Exception ex)
12-
{
13-
var apiex = ex as ApiException;
14-
return apiex?.HttpResponse?.Headers.ContainsKey(GithubHeader) ?? false;
15-
}
16-
17-
public static string FirstErrorMessageSafe(this ApiError apiError)
18-
{
19-
if (apiError == null) return null;
20-
if (apiError.Errors == null) return apiError.Message;
21-
var firstError = apiError.Errors.FirstOrDefault();
22-
return firstError == null ? null : firstError.Message;
23-
}
24-
25-
}
26-
276
static class ExceptionExtensions
287
{
298
/// <summary>

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Threading;
5-
using System.Threading.Tasks;
6-
using Octokit;
74
using GitHub.Logging;
85

96
namespace GitHub.Unity

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
<Compile Include="Application\ApplicationInfo.cs" />
9696
<Compile Include="Application\LoginResult.cs" />
9797
<Compile Include="Application\ApplicationConfiguration.cs" />
98-
<Compile Include="Application\OctokitExtensions.cs" />
9998
<Compile Include="Application\Organization.cs" />
10099
<Compile Include="Cache\CacheInterfaces.cs" />
101100
<Compile Include="Extensions\ListExtensions.cs" />

0 commit comments

Comments
 (0)