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

Commit 4511bb7

Browse files
committed
Merge branch 'master' into refactor/xmlnsdefinition
Conflicts: src/GitHub.VisualStudio/Views/GitHubPane/PullRequestListItem.xaml
2 parents 61ea013 + 6166b0d commit 4511bb7

File tree

116 files changed

+2309
-1588
lines changed

Some content is hidden

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

116 files changed

+2309
-1588
lines changed

GitHubVS.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.InlineReviews.UnitTe
104104
EndProject
105105
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.Logging", "src\GitHub.Logging\GitHub.Logging.csproj", "{8D73575A-A89F-47CC-B153-B47DD06837F0}"
106106
EndProject
107+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.Services.Vssdk", "src\GitHub.Services.Vssdk\GitHub.Services.Vssdk.csproj", "{2D3D2834-33BE-45CA-B3CC-12F853557D7B}"
108+
EndProject
107109
Global
108110
GlobalSection(SolutionConfigurationPlatforms) = preSolution
109111
Debug|Any CPU = Debug|Any CPU
@@ -403,6 +405,16 @@ Global
403405
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Release|Any CPU.Build.0 = Release|Any CPU
404406
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
405407
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
408+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
409+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
410+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.DebugCodeAnalysis|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
411+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.DebugCodeAnalysis|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
412+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.DebugWithoutVsix|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
413+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.DebugWithoutVsix|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
414+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
415+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.Release|Any CPU.Build.0 = Release|Any CPU
416+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
417+
{2D3D2834-33BE-45CA-B3CC-12F853557D7B}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
406418
EndGlobalSection
407419
GlobalSection(SolutionProperties) = preSolution
408420
HideSolutionNode = FALSE

appveyor.yml

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

src/GitHub.App/GitHub.App.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@
311311
<Project>{8d73575a-a89f-47cc-b153-b47dd06837f0}</Project>
312312
<Name>GitHub.Logging</Name>
313313
</ProjectReference>
314+
<ProjectReference Include="..\GitHub.Services.Vssdk\GitHub.Services.Vssdk.csproj">
315+
<Project>{2D3D2834-33BE-45CA-B3CC-12F853557D7B}</Project>
316+
<Name>GitHub.Services.Vssdk</Name>
317+
</ProjectReference>
314318
<ProjectReference Include="..\GitHub.UI.Reactive\GitHub.UI.Reactive.csproj">
315319
<Project>{158b05e8-fdbc-4d71-b871-c96e28d5adf5}</Project>
316320
<Name>GitHub.UI.Reactive</Name>

src/GitHub.App/SampleData/PullRequestListViewModelDesigner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public PullRequestListViewModelDesigner()
5858

5959
public IReadOnlyList<IRemoteRepositoryModel> Repositories { get; }
6060
public IRemoteRepositoryModel SelectedRepository { get; set; }
61-
61+
public IPullRequestModel CheckedOutPullRequest { get; set; }
6262
public ITrackingCollection<IPullRequestModel> PullRequests { get; set; }
6363
public IPullRequestModel SelectedPullRequest { get; set; }
6464

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

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel.Composition;
3+
using System.ComponentModel.Design;
34
using System.Linq;
45
using System.Reactive;
56
using System.Reactive.Linq;
@@ -15,6 +16,7 @@
1516
using GitHub.Models;
1617
using GitHub.Primitives;
1718
using GitHub.Services;
19+
using GitHub.Services.Vssdk.Commands;
1820
using GitHub.VisualStudio;
1921
using ReactiveUI;
2022
using Serilog;
@@ -36,8 +38,6 @@ public sealed class GitHubPaneViewModel : ViewModelBase, IGitHubPaneViewModel, I
3638
readonly ISimpleApiClientFactory apiClientFactory;
3739
readonly IConnectionManager connectionManager;
3840
readonly ITeamExplorerContext teamExplorerContext;
39-
readonly IVisualStudioBrowser browser;
40-
readonly IUsageTracker usageTracker;
4141
readonly INavigationViewModel navigator;
4242
readonly ILoggedOutViewModel loggedOut;
4343
readonly INotAGitHubRepositoryViewModel notAGitHubRepository;
@@ -49,8 +49,8 @@ public sealed class GitHubPaneViewModel : ViewModelBase, IGitHubPaneViewModel, I
4949
readonly ReactiveCommand<Unit> refresh;
5050
readonly ReactiveCommand<Unit> showPullRequests;
5151
readonly ReactiveCommand<object> openInBrowser;
52-
readonly SemaphoreSlim initializing = new SemaphoreSlim(1);
53-
bool initialized;
52+
readonly ReactiveCommand<object> help;
53+
Task initializeTask;
5454
IViewModel content;
5555
ILocalRepositoryModel localRepository;
5656
string searchQuery;
@@ -83,8 +83,6 @@ public GitHubPaneViewModel(
8383
this.apiClientFactory = apiClientFactory;
8484
this.connectionManager = connectionManager;
8585
this.teamExplorerContext = teamExplorerContext;
86-
this.browser = browser;
87-
this.usageTracker = usageTracker;
8886
this.navigator = navigator;
8987
this.loggedOut = loggedOut;
9088
this.notAGitHubRepository = notAGitHubRepository;
@@ -148,6 +146,13 @@ public GitHubPaneViewModel(
148146
if (url != null) browser.OpenUrl(url);
149147
});
150148

149+
help = ReactiveCommand.Create();
150+
help.Subscribe(_ =>
151+
{
152+
browser.OpenUrl(new Uri(GitHubUrls.Documentation));
153+
usageTracker.IncrementCounter(x => x.NumberOfGitHubPaneHelpClicks).Forget();
154+
});
155+
151156
navigator.WhenAnyObservable(x => x.Content.NavigationRequested)
152157
.Subscribe(x => NavigateTo(x).Forget());
153158

@@ -201,39 +206,9 @@ public void Dispose()
201206
}
202207

203208
/// <inheritdoc/>
204-
public async Task InitializeAsync(IServiceProvider paneServiceProvider)
209+
public Task InitializeAsync(IServiceProvider paneServiceProvider)
205210
{
206-
await initializing.WaitAsync();
207-
if (initialized) return;
208-
209-
try
210-
{
211-
await UpdateContent(teamExplorerContext.ActiveRepository);
212-
teamExplorerContext.WhenAnyValue(x => x.ActiveRepository)
213-
.Skip(1)
214-
.ObserveOn(RxApp.MainThreadScheduler)
215-
.Subscribe(x => UpdateContent(x).Forget());
216-
217-
connectionManager.Connections.CollectionChanged += (_, __) => UpdateContent(LocalRepository).Forget();
218-
219-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.pullRequestCommand, showPullRequests);
220-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.backCommand, navigator.NavigateBack);
221-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.forwardCommand, navigator.NavigateForward);
222-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.refreshCommand, refresh);
223-
BindNavigatorCommand(paneServiceProvider, PkgCmdIDList.githubCommand, openInBrowser);
224-
225-
paneServiceProvider.AddCommandHandler(Guids.guidGitHubToolbarCmdSet, PkgCmdIDList.helpCommand,
226-
(_, __) =>
227-
{
228-
browser.OpenUrl(new Uri(GitHubUrls.Documentation));
229-
usageTracker.IncrementCounter(x => x.NumberOfGitHubPaneHelpClicks).Forget();
230-
});
231-
}
232-
finally
233-
{
234-
initialized = true;
235-
initializing.Release();
236-
}
211+
return initializeTask = initializeTask ?? CreateInitializeTask(paneServiceProvider);
237212
}
238213

239214
/// <inheritdoc/>
@@ -307,27 +282,31 @@ public Task ShowPullRequest(string owner, string repo, int number)
307282
x => x.RemoteRepositoryOwner == owner && x.LocalRepository.Name == repo && x.Number == number);
308283
}
309284

310-
OleMenuCommand BindNavigatorCommand<T>(IServiceProvider paneServiceProvider, int commandId, ReactiveCommand<T> command)
285+
async Task CreateInitializeTask(IServiceProvider paneServiceProvider)
311286
{
312-
Guard.ArgumentNotNull(paneServiceProvider, nameof(paneServiceProvider));
313-
Guard.ArgumentNotNull(command, nameof(command));
314-
315-
Func<bool> canExecute = () => Content == navigator && command.CanExecute(null);
316-
317-
var result = paneServiceProvider.AddCommandHandler(
318-
Guids.guidGitHubToolbarCmdSet,
319-
commandId,
320-
canExecute,
321-
() => command.Execute(null),
322-
true);
287+
await UpdateContent(teamExplorerContext.ActiveRepository);
288+
teamExplorerContext.WhenAnyValue(x => x.ActiveRepository)
289+
.Skip(1)
290+
.ObserveOn(RxApp.MainThreadScheduler)
291+
.Subscribe(x => UpdateContent(x).Forget());
292+
293+
connectionManager.Connections.CollectionChanged += (_, __) => UpdateContent(LocalRepository).Forget();
294+
295+
var menuService = (IMenuCommandService)paneServiceProvider.GetService(typeof(IMenuCommandService));
296+
BindNavigatorCommand(menuService, PkgCmdIDList.pullRequestCommand, showPullRequests);
297+
BindNavigatorCommand(menuService, PkgCmdIDList.backCommand, navigator.NavigateBack);
298+
BindNavigatorCommand(menuService, PkgCmdIDList.forwardCommand, navigator.NavigateForward);
299+
BindNavigatorCommand(menuService, PkgCmdIDList.refreshCommand, refresh);
300+
BindNavigatorCommand(menuService, PkgCmdIDList.githubCommand, openInBrowser);
301+
BindNavigatorCommand(menuService, PkgCmdIDList.helpCommand, help);
302+
}
323303

324-
Observable.CombineLatest(
325-
this.WhenAnyValue(x => x.Content),
326-
command.CanExecuteObservable,
327-
(c, e) => c == navigator && e)
328-
.Subscribe(x => result.Enabled = x);
304+
OleMenuCommand BindNavigatorCommand<T>(IMenuCommandService menu, int commandId, ReactiveCommand<T> command)
305+
{
306+
Guard.ArgumentNotNull(menu, nameof(menu));
307+
Guard.ArgumentNotNull(command, nameof(command));
329308

330-
return result;
309+
return menu.BindCommand(new CommandID(Guids.guidGitHubToolbarCmdSet, commandId), command);
331310
}
332311

333312
async Task NavigateTo<TViewModel>(Func<TViewModel, Task> initialize, Func<TViewModel, bool> match = null)

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public class PullRequestListViewModel : PanePageViewModelBase, IPullRequestListV
4141
public PullRequestListViewModel(
4242
IModelServiceFactory modelServiceFactory,
4343
IPackageSettings settings,
44+
IPullRequestSessionManager sessionManager,
4445
IVisualStudioBrowser visualStudioBrowser)
4546
{
4647
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
4748
Guard.ArgumentNotNull(settings, nameof(settings));
49+
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
4850
Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser));
4951

5052
constructing = true;
@@ -100,6 +102,19 @@ public PullRequestListViewModel(
100102
OpenPullRequestOnGitHub = ReactiveCommand.Create();
101103
OpenPullRequestOnGitHub.Subscribe(x => DoOpenPullRequestOnGitHub((int)x));
102104

105+
// Get the current pull request session and the selected repository. When the session's
106+
// repository is the same as our selected repository set CheckedOutPullRequest to the
107+
// current session's model, so that the checked out PR can be highlighted.
108+
Observable.CombineLatest(
109+
sessionManager.WhenAnyValue(x => x.CurrentSession),
110+
this.WhenAnyValue(x => x.SelectedRepository),
111+
(s, r) => new { Session = s, Repository = r })
112+
.Subscribe(x =>
113+
{
114+
CheckedOutPullRequest = x.Session?.RepositoryOwner == x.Repository?.Owner ?
115+
x.Session?.PullRequest : null;
116+
});
117+
103118
constructing = false;
104119
}
105120

@@ -245,6 +260,13 @@ public IPullRequestModel SelectedPullRequest
245260
set { this.RaiseAndSetIfChanged(ref selectedPullRequest, value); }
246261
}
247262

263+
IPullRequestModel checkedOutPullRequest;
264+
public IPullRequestModel CheckedOutPullRequest
265+
{
266+
get { return checkedOutPullRequest; }
267+
set { this.RaiseAndSetIfChanged(ref checkedOutPullRequest, value); }
268+
}
269+
248270
IReadOnlyList<PullRequestState> states;
249271
public IReadOnlyList<PullRequestState> States
250272
{

src/GitHub.Exports.Reactive/ViewModels/GitHubPane/IPullRequestListViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public interface IPullRequestListViewModel : ISearchablePageViewModel, IOpenInBr
3333
IRemoteRepositoryModel SelectedRepository { get; set; }
3434
ITrackingCollection<IPullRequestModel> PullRequests { get; }
3535
IPullRequestModel SelectedPullRequest { get; }
36+
IPullRequestModel CheckedOutPullRequest { get; }
3637
IReadOnlyList<PullRequestState> States { get; set; }
3738
PullRequestState SelectedState { get; set; }
3839
ObservableCollection<IAccount> Authors { get; }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace GitHub.Commands
4+
{
5+
/// <summary>
6+
/// Opens the login dialog to add a new connection to Team Explorer.
7+
/// </summary>
8+
public interface IAddConnectionCommand : IVsCommand
9+
{
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace GitHub.Commands
4+
{
5+
/// <summary>
6+
/// Opens the blame view for the currently selected text on GitHub.com or an Enterprise
7+
/// instance.
8+
/// </summary>
9+
public interface IBlameLinkCommand : IVsCommand
10+
{
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace GitHub.Commands
4+
{
5+
/// <summary>
6+
/// Copies a link to the clipboard of the currently selected text on GitHub.com or an
7+
/// Enterprise instance.
8+
/// </summary>
9+
public interface ICopyLinkCommand : IVsCommand
10+
{
11+
}
12+
}

0 commit comments

Comments
 (0)