Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 484efb8

Browse files
committed
Merge master into localization
Conflicts: src/GitHub.VisualStudio/UI/Views/GitHubConnectContent.xaml
2 parents 5181585 + f615190 commit 484efb8

File tree

82 files changed

+1876
-312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1876
-312
lines changed

lib/LibGit2Sharp.dll

363 KB
Binary file not shown.

script

src/CredentialManagement/CredentialSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public CredentialSet()
1818
public CredentialSet(string target)
1919
: this()
2020
{
21-
Guard.ArgumentNotEmptyString(target, "target");
21+
Guard.ArgumentNotEmptyString(target, nameof(target));
2222

2323
Target = target;
2424
}

src/GitHub.Api/SimpleApiClient.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class SimpleApiClient : ISimpleApiClient
1313
public HostAddress HostAddress { get; }
1414
public UriString OriginalUrl { get; }
1515

16-
readonly GitHubClient client;
16+
readonly IGitHubClient client;
1717
readonly Lazy<IEnterpriseProbeTask> enterpriseProbe;
1818
readonly Lazy<IWikiProbe> wikiProbe;
1919
static readonly SemaphoreSlim sem = new SemaphoreSlim(1);
@@ -23,7 +23,7 @@ public class SimpleApiClient : ISimpleApiClient
2323
bool? isEnterprise;
2424
bool? hasWiki;
2525

26-
internal SimpleApiClient(HostAddress hostAddress, UriString repoUrl, GitHubClient githubClient,
26+
public SimpleApiClient(HostAddress hostAddress, UriString repoUrl, IGitHubClient githubClient,
2727
Lazy<IEnterpriseProbeTask> enterpriseProbe, Lazy<IWikiProbe> wikiProbe)
2828
{
2929
HostAddress = hostAddress;
@@ -78,16 +78,12 @@ async Task<Repository> GetRepositoryInternal()
7878

7979
public bool HasWiki()
8080
{
81-
if (hasWiki.HasValue)
82-
return hasWiki.Value;
83-
return false;
81+
return hasWiki.HasValue && hasWiki.Value;
8482
}
8583

8684
public bool IsEnterprise()
8785
{
88-
if (isEnterprise.HasValue)
89-
return isEnterprise.Value;
90-
return false;
86+
return isEnterprise.HasValue && isEnterprise.Value;
9187
}
9288

9389
async Task<bool> HasWikiInternal(Repository repo)
@@ -108,8 +104,6 @@ async Task<bool> HasWikiInternal(Repository repo)
108104
return false;
109105
#endif
110106
var ret = await probe.ProbeAsync(repo);
111-
if (ret == WikiProbeResult.Failed)
112-
return false;
113107
return (ret == WikiProbeResult.Ok);
114108
}
115109

@@ -122,8 +116,6 @@ async Task<bool> IsEnterpriseInternal()
122116
return false;
123117
#endif
124118
var ret = await probe.ProbeAsync(HostAddress.WebUri);
125-
if (ret == EnterpriseProbeResult.Failed)
126-
return false;
127119
return (ret == EnterpriseProbeResult.Ok);
128120
}
129121
}
Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel.Composition;
34
using GitHub.Models;
45
using GitHub.Primitives;
56
using GitHub.Services;
67
using Octokit;
7-
using System.Collections.Generic;
8+
using System.Collections.Concurrent;
89

910
namespace GitHub.Api
1011
{
@@ -16,7 +17,7 @@ public class SimpleApiClientFactory : ISimpleApiClientFactory
1617
readonly Lazy<IEnterpriseProbeTask> lazyEnterpriseProbe;
1718
readonly Lazy<IWikiProbe> lazyWikiProbe;
1819

19-
static readonly Dictionary<UriString, ISimpleApiClient> cache = new Dictionary<UriString, ISimpleApiClient>();
20+
static readonly ConcurrentDictionary<UriString, ISimpleApiClient> cache = new ConcurrentDictionary<UriString, ISimpleApiClient>();
2021

2122
[ImportingConstructor]
2223
public SimpleApiClientFactory(IProgram program, Lazy<IEnterpriseProbeTask> enterpriseProbe, Lazy<IWikiProbe> wikiProbe)
@@ -28,29 +29,16 @@ public SimpleApiClientFactory(IProgram program, Lazy<IEnterpriseProbeTask> enter
2829

2930
public ISimpleApiClient Create(UriString repositoryUrl)
3031
{
31-
var contains = cache.ContainsKey(repositoryUrl);
32-
if (contains)
33-
return cache[repositoryUrl];
34-
35-
lock (cache)
36-
{
37-
if (!cache.ContainsKey(repositoryUrl))
38-
{
39-
var hostAddress = HostAddress.Create(repositoryUrl);
40-
var apiBaseUri = hostAddress.ApiUri;
41-
cache.Add(repositoryUrl, new SimpleApiClient(hostAddress, repositoryUrl, new GitHubClient(productHeader, new SimpleCredentialStore(hostAddress), apiBaseUri), lazyEnterpriseProbe, lazyWikiProbe));
42-
}
43-
return cache[repositoryUrl];
44-
}
32+
var hostAddress = HostAddress.Create(repositoryUrl);
33+
return cache.GetOrAdd(repositoryUrl, new SimpleApiClient(hostAddress, repositoryUrl,
34+
new GitHubClient(productHeader, new SimpleCredentialStore(hostAddress), hostAddress.ApiUri),
35+
lazyEnterpriseProbe, lazyWikiProbe));
4536
}
4637

4738
public void ClearFromCache(ISimpleApiClient client)
4839
{
49-
lock (cache)
50-
{
51-
if (cache.ContainsKey(client.OriginalUrl))
52-
cache.Remove(client.OriginalUrl);
53-
}
40+
ISimpleApiClient c;
41+
cache.TryRemove(client.OriginalUrl, out c);
5442
}
5543
}
5644
}

src/GitHub.App/Api/ApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public ApiClient(HostAddress hostAddress, IObservableGitHubClient gitHubClient)
4646

4747
public IObservable<Repository> CreateRepository(NewRepository repository, string login, bool isUser)
4848
{
49-
Guard.ArgumentNotEmptyString(login, "login");
49+
Guard.ArgumentNotEmptyString(login, nameof(login));
5050

5151
var client = gitHubClient.Repository;
5252

src/GitHub.App/Caches/CredentialCache.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class CredentialCache : ISecureBlobCache, IObjectBlobCache
1616
public IScheduler Scheduler { get; protected set; }
1717

1818
readonly AsyncSubject<Unit> shutdown = new AsyncSubject<Unit>();
19-
public IObservable<Unit> Shutdown { get { return shutdown; } }
19+
public IObservable<Unit> Shutdown => shutdown;
2020

2121
public IObservable<Unit> Flush()
2222
{
@@ -84,7 +84,7 @@ public IObservable<Unit> Vacuum()
8484
{
8585
if (disposed) return ExceptionHelper.ObservableThrowObjectDisposedException<Unit>("CredentialCache");
8686

87-
Tuple<string, string> values = value as Tuple<string, string>;
87+
var values = value as Tuple<string, string>;
8888
if (values == null)
8989
return ExceptionHelper.ObservableThrowInvalidOperationException<Unit>(key);
9090

@@ -112,9 +112,9 @@ IObservable<Tuple<string, string>> GetTuple(string key)
112112

113113
var keyHost = GetKeyHost(key);
114114
var ret = GetKey(keyHost);
115-
if (ret != null)
116-
return Observable.Return(ret);
117-
return ExceptionHelper.ObservableThrowKeyNotFoundException<Tuple<string, string>>(keyHost);
115+
return ret != null
116+
? Observable.Return(ret)
117+
: ExceptionHelper.ObservableThrowKeyNotFoundException<Tuple<string, string>>(keyHost);
118118
}
119119

120120
public IObservable<IEnumerable<T>> GetAllObjects<T>()
@@ -180,9 +180,7 @@ static bool DeleteKey(string key)
180180
using (var credential = new Credential())
181181
{
182182
credential.Target = key;
183-
if (!credential.Load())
184-
return false;
185-
return credential.Delete();
183+
return credential.Load() && credential.Delete();
186184
}
187185
}
188186

@@ -202,9 +200,9 @@ static Tuple<string, string> GetKey(string key)
202200
{
203201
credential.Target = key;
204202
credential.Type = CredentialType.Generic;
205-
if (credential.Load())
206-
return new Tuple<string, string>(credential.Username, credential.Password);
207-
return null;
203+
return credential.Load()
204+
? new Tuple<string, string>(credential.Username, credential.Password)
205+
: null;
208206
}
209207
}
210208

src/GitHub.App/Caches/ImageCache.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ void Dispose(bool disposing)
239239
public void Dispose()
240240
{
241241
Dispose(true);
242-
GC.SuppressFinalize(this);
243242
}
244243

245244
class UriComparer : IEqualityComparer<Uri>

src/GitHub.App/Caches/LoginCache.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public IObservable<LoginInfo> GetLoginAsync(HostAddress hostAddress)
3737

3838
public IObservable<Unit> SaveLogin(string user, string password, HostAddress hostAddress)
3939
{
40-
Guard.ArgumentNotEmptyString(user, "user");
41-
Guard.ArgumentNotEmptyString(password, "password");
40+
Guard.ArgumentNotEmptyString(user, nameof(user));
41+
Guard.ArgumentNotEmptyString(password, nameof(password));
4242

4343
return cache.Secure.SaveLogin(user, password, hostAddress.CredentialCacheKeyHost);
4444
}
@@ -78,7 +78,6 @@ void Dispose(bool disposing)
7878
public void Dispose()
7979
{
8080
Dispose(true);
81-
GC.SuppressFinalize(this);
8281
}
8382
}
8483
}

src/GitHub.App/Controllers/UIController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ protected virtual void Dispose(bool disposing)
272272

273273
Debug.WriteLine("Disposing ({0})", GetHashCode());
274274
disposables.Dispose();
275-
if (transition != null)
276-
transition.Dispose();
275+
transition?.Dispose();
277276
disposed = true;
278277
}
279278
}

0 commit comments

Comments
 (0)