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

Commit a209e5f

Browse files
authored
Merge branch 'master' into feature/submodule-changes-progress-on-statusbar
2 parents 9f66011 + ed53149 commit a209e5f

File tree

35 files changed

+1418
-681
lines changed

35 files changed

+1418
-681
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2.4.2.{build}'
1+
version: '2.4.3.{build}'
22
skip_tags: true
33
install:
44
- ps: |

src/GitHub.Api/SimpleApiClient.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async Task<Repository> GetRepositoryInternal()
7272
if (repo != null)
7373
{
7474
hasWiki = await HasWikiInternal(repo);
75-
isEnterprise = await IsEnterpriseInternal();
75+
isEnterprise = isEnterprise ?? await IsEnterpriseInternal();
7676
repositoryCache = repo;
7777
}
7878
owner = ownerLogin;
@@ -99,9 +99,14 @@ public bool HasWiki()
9999
return hasWiki.HasValue && hasWiki.Value;
100100
}
101101

102-
public bool IsEnterprise()
102+
public async Task<bool> IsEnterprise()
103103
{
104-
return isEnterprise.HasValue && isEnterprise.Value;
104+
if (!isEnterprise.HasValue)
105+
{
106+
isEnterprise = await IsEnterpriseInternal();
107+
}
108+
109+
return isEnterprise ?? false;
105110
}
106111

107112
async Task<bool> HasWikiInternal(Repository repo)

src/GitHub.App/Api/ApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static string GetMachineNameSafe()
157157
}
158158
catch (Exception e)
159159
{
160-
log.Information(e, "Failed to retrieve host name using `DNS.GetHostName`");
160+
log.Warning(e, "Failed to retrieve host name using `DNS.GetHostName`");
161161
try
162162
{
163163
return Environment.MachineName;

src/GitHub.App/GitHub.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
<Compile Include="Models\PullRequestDetailArgument.cs" />
155155
<Compile Include="Services\EnterpriseCapabilitiesService.cs" />
156156
<Compile Include="Services\GlobalConnection.cs" />
157+
<Compile Include="Services\PullRequestEditorService.cs" />
157158
<Compile Include="Services\TeamExplorerContext.cs" />
158159
<Compile Include="Services\OAuthCallbackListener.cs" />
159160
<Compile Include="ViewModels\Dialog\GistCreationViewModel.cs" />

src/GitHub.Exports.Reactive/Services/PullRequestEditorService.cs renamed to src/GitHub.App/Services/PullRequestEditorService.cs

File renamed without changes.

src/GitHub.App/Services/TeamExplorerContext.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void Refresh()
6565
{
6666
// Ignore when ActiveRepositories is empty and solution hasn't changed.
6767
// https://github.com/github/VisualStudio/issues/1421
68-
log.Information("Ignoring no ActiveRepository when solution hasn't changed");
68+
log.Debug("Ignoring no ActiveRepository when solution hasn't changed");
6969
}
7070
else
7171
{
@@ -76,22 +76,22 @@ void Refresh()
7676

7777
if (newRepositoryPath != repositoryPath)
7878
{
79-
log.Information("Fire PropertyChanged event for ActiveRepository");
79+
log.Debug("Fire PropertyChanged event for ActiveRepository");
8080
ActiveRepository = repo;
8181
}
8282
else if (newBranchName != branchName)
8383
{
84-
log.Information("Fire StatusChanged event when BranchName changes for ActiveRepository");
84+
log.Debug("Fire StatusChanged event when BranchName changes for ActiveRepository");
8585
StatusChanged?.Invoke(this, EventArgs.Empty);
8686
}
8787
else if (newHeadSha != headSha)
8888
{
89-
log.Information("Fire StatusChanged event when HeadSha changes for ActiveRepository");
89+
log.Debug("Fire StatusChanged event when HeadSha changes for ActiveRepository");
9090
StatusChanged?.Invoke(this, EventArgs.Empty);
9191
}
9292
else if (newTrackedSha != trackedSha)
9393
{
94-
log.Information("Fire StatusChanged event when TrackedSha changes for ActiveRepository");
94+
log.Debug("Fire StatusChanged event when TrackedSha changes for ActiveRepository");
9595
StatusChanged?.Invoke(this, EventArgs.Empty);
9696
}
9797

src/GitHub.App/ViewModels/Dialog/LoginTabViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void HandleError(Exception ex)
200200

201201
if (ex.IsCriticalException()) return;
202202

203-
log.Information(ex, "Error logging into '{BaseUri}' as '{UsernameOrEmail}'", BaseUri, UsernameOrEmail);
203+
log.Error(ex, "Error logging into '{BaseUri}' as '{UsernameOrEmail}'", BaseUri, UsernameOrEmail);
204204
if (ex is Octokit.ForbiddenException)
205205
{
206206
Error = new UserError(Resources.LoginFailedForbiddenMessage, ex.Message);

src/GitHub.App/ViewModels/GitHubPane/GitHubPaneViewModel.cs

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public sealed class GitHubPaneViewModel : ViewModelBase, IGitHubPaneViewModel, I
4646
readonly ReactiveCommand<Unit> refresh;
4747
readonly ReactiveCommand<Unit> showPullRequests;
4848
readonly ReactiveCommand<object> openInBrowser;
49+
readonly SemaphoreSlim initializing = new SemaphoreSlim(1);
50+
bool initialized;
4951
IViewModel content;
5052
ILocalRepositoryModel localRepository;
5153
string searchQuery;
@@ -198,26 +200,37 @@ public void Dispose()
198200
/// <inheritdoc/>
199201
public async Task InitializeAsync(IServiceProvider paneServiceProvider)
200202
{
201-
await UpdateContent(teamExplorerContext.ActiveRepository);
202-
teamExplorerContext.WhenAnyValue(x => x.ActiveRepository)
203-
.Skip(1)
204-
.ObserveOn(RxApp.MainThreadScheduler)
205-
.Subscribe(x => UpdateContent(x).Forget());
206-
207-
connectionManager.Connections.CollectionChanged += (_, __) => UpdateContent(LocalRepository).Forget();
208-
209-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.pullRequestCommand, showPullRequests);
210-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.backCommand, navigator.NavigateBack);
211-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.forwardCommand, navigator.NavigateForward);
212-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.refreshCommand, refresh);
213-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.githubCommand, openInBrowser);
214-
215-
paneServiceProvider.AddCommandHandler(Guids.guidGitHubToolbarCmdSet, PkgCmdIDList.helpCommand,
216-
(_, __) =>
217-
{
218-
browser.OpenUrl(new Uri(GitHubUrls.Documentation));
219-
usageTracker.IncrementCounter(x => x.NumberOfGitHubPaneHelpClicks).Forget();
220-
});
203+
await initializing.WaitAsync();
204+
if (initialized) return;
205+
206+
try
207+
{
208+
await UpdateContent(teamExplorerContext.ActiveRepository);
209+
teamExplorerContext.WhenAnyValue(x => x.ActiveRepository)
210+
.Skip(1)
211+
.ObserveOn(RxApp.MainThreadScheduler)
212+
.Subscribe(x => UpdateContent(x).Forget());
213+
214+
connectionManager.Connections.CollectionChanged += (_, __) => UpdateContent(LocalRepository).Forget();
215+
216+
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.pullRequestCommand, showPullRequests);
217+
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.backCommand, navigator.NavigateBack);
218+
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.forwardCommand, navigator.NavigateForward);
219+
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.refreshCommand, refresh);
220+
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.githubCommand, openInBrowser);
221+
222+
paneServiceProvider.AddCommandHandler(Guids.guidGitHubToolbarCmdSet, PkgCmdIDList.helpCommand,
223+
(_, __) =>
224+
{
225+
browser.OpenUrl(new Uri(GitHubUrls.Documentation));
226+
usageTracker.IncrementCounter(x => x.NumberOfGitHubPaneHelpClicks).Forget();
227+
});
228+
}
229+
finally
230+
{
231+
initialized = true;
232+
initializing.Release();
233+
}
221234
}
222235

223236
/// <inheritdoc/>
@@ -366,7 +379,7 @@ async Task UpdateContent(ILocalRepositoryModel repository)
366379
var repositoryUrl = repository.CloneUrl.ToRepositoryUrl();
367380
var isDotCom = HostAddress.IsGitHubDotComUri(repositoryUrl);
368381
var client = await apiClientFactory.Create(repository.CloneUrl);
369-
var isEnterprise = isDotCom ? false : client.IsEnterprise();
382+
var isEnterprise = isDotCom ? false : await client.IsEnterprise();
370383

371384
if ((isDotCom || isEnterprise) && await IsValidRepository(client))
372385
{

src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@
182182
<Compile Include="Services\IShowDialogService.cs" />
183183
<Compile Include="Services\LocalRepositoriesExtensions.cs" />
184184
<Compile Include="Services\ModelServiceExtensions.cs" />
185-
<Compile Include="Services\PullRequestEditorService.cs" />
186185
<Compile Include="ViewModels\Dialog\IDialogContentViewModel.cs" />
187186
<Compile Include="ViewModels\Dialog\IGitHubDialogWindowViewModel.cs" />
188187
<Compile Include="ViewModels\Dialog\IGistCreationViewModel.cs" />

src/GitHub.Exports.Reactive/Services/IPullRequestSessionManager.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public interface IPullRequestSessionManager : INotifyPropertyChanged
3131
/// </returns>
3232
IPullRequestSession CurrentSession { get; }
3333

34+
/// <summary>
35+
/// Ensures that the service is initialized.
36+
/// </summary>
37+
/// <returns>A task that when completed indicates that the service is initialized.</returns>
38+
/// <remarks>
39+
/// If you are simply monitoring changes to the <see cref="CurrentSession"/> then you
40+
/// don't need to call this method: <see cref="CurrentSession"/> will be updated on
41+
/// initialization. If however, you want to be sure that <see cref="CurrentSession"/> is
42+
/// initialized, you can await the task returned from this method.
43+
/// </remarks>
44+
Task EnsureInitialized();
45+
3446
/// <summary>
3547
/// Gets an <see cref="IPullRequestSessionFile"/> that tracks the live state of a document.
3648
/// </summary>

0 commit comments

Comments
 (0)