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

Commit e9b547a

Browse files
authored
Merge branch 'master' into fixes/1666-filter-pr-solution-explorer
2 parents 0b1a752 + dc745e5 commit e9b547a

36 files changed

+456
-303
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.5.1.{build}'
1+
version: '2.5.2.{build}'
22
skip_tags: true
33
install:
44
- ps: |

src/GitHub.App/Models/Account.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public Account(Octokit.Account account, IObservable<BitmapSource> bitmapSource)
8080

8181
public long PrivateReposInPlan { get; private set; }
8282

83-
public string AvatarUrl { get; private set; }
83+
public string AvatarUrl { get; set; }
8484

8585
public BitmapSource Avatar
8686
{

src/GitHub.App/SampleData/ForkRepositoryExecuteViewModelDesigner.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public ForkRepositoryExecuteViewModelDesigner()
3030

3131
public IObservable<object> Done => null;
3232

33+
public IObservable<object> Back => null;
34+
3335
public string Title => null;
3436

3537
public IRepositoryModel SourceRepository { get; set; }
@@ -40,6 +42,8 @@ public ForkRepositoryExecuteViewModelDesigner()
4042

4143
public IReactiveCommand<Repository> CreateFork => null;
4244

45+
public IReactiveCommand<object> BackCommand => null;
46+
4347
public bool ResetMasterTracking { get; set; } = true;
4448

4549
public bool AddUpstream { get; set; } = true;

src/GitHub.App/SampleData/ForkRepositorySelectViewModelDesigner.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public ForkRepositorySelectViewModelDesigner()
1414
{
1515
Accounts = new[]
1616
{
17-
new AccountDesigner { Login = "Myself" },
18-
new AccountDesigner { Login = "MyOrg1" },
19-
new AccountDesigner { Login = "MyOrg2" },
20-
new AccountDesigner { Login = "MyOrg3" },
21-
new AccountDesigner { Login = "a-long-org-name" },
17+
new AccountDesigner { Login = "Myself", AvatarUrl = "https://identicons.github.com/myself.png" },
18+
new AccountDesigner { Login = "MyOrg1", AvatarUrl = "https://identicons.github.com/myorg1.png" },
19+
new AccountDesigner { Login = "MyOrg2", AvatarUrl = "https://identicons.github.com/myorg2.png" },
20+
new AccountDesigner { Login = "MyOrg3", AvatarUrl = "https://identicons.github.com/myorg3.png" },
21+
new AccountDesigner { Login = "a-long-org-name", AvatarUrl = "https://identicons.github.com/a-long-org-name.png" },
2222
};
2323

2424
ExistingForks = new[]

src/GitHub.App/Services/RepositoryForkService.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public IObservable<Repository> ForkRepository(IApiClient apiClient, IRepositoryM
4141
log.Verbose("ForkRepository Source:{SourceOwner}/{SourceName} To:{DestinationOwner}", sourceRepository.Owner, sourceRepository.Name, repositoryFork.Organization ?? "[Current User]");
4242
log.Verbose("ForkRepository updateOrigin:{UpdateOrigin} addUpstream:{AddUpstream} trackMasterUpstream:{TrackMasterUpstream}", updateOrigin, addUpstream, trackMasterUpstream);
4343

44-
RecordForkRepositoryUsage(updateOrigin, addUpstream, trackMasterUpstream).Forget();
44+
usageTracker.IncrementCounter(model => model.NumberOfReposForked).Forget();
4545

4646
return Observable.Defer(() => apiClient.ForkRepository(sourceRepository.Owner, sourceRepository.Name, repositoryFork)
4747
.ObserveOn(RxApp.MainThreadScheduler)
@@ -63,26 +63,6 @@ public IObservable<Repository> ForkRepository(IApiClient apiClient, IRepositoryM
6363
});
6464
}
6565

66-
private async Task RecordForkRepositoryUsage(bool updateOrigin, bool addUpstream, bool trackMasterUpstream)
67-
{
68-
await usageTracker.IncrementCounter(model => model.NumberOfReposForked);
69-
70-
if (updateOrigin)
71-
{
72-
await usageTracker.IncrementCounter(model => model.NumberOfOriginsUpdatedWhenForkingRepo);
73-
}
74-
75-
if (addUpstream)
76-
{
77-
await usageTracker.IncrementCounter(model => model.NumberOfUpstreamsAddedWhenForkingRepo);
78-
}
79-
80-
if (trackMasterUpstream)
81-
{
82-
await usageTracker.IncrementCounter(model => model.NumberOfTrackMasterUpstreamWhenForkingRepo);
83-
}
84-
}
85-
8666
public IObservable<object> SwitchRemotes(IRepositoryModel destinationRepository, bool updateOrigin, bool addUpstream, bool trackMasterUpstream)
8767
{
8868
return Observable.Defer(() => Observable.Return(new object())

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ IRepositoryForkService repositoryForkService
4545
.Subscribe(tuple => CanResetMasterTracking = tuple.Item1 && tuple.Item2);
4646

4747
CreateFork = ReactiveCommand.CreateAsyncObservable(OnCreateFork);
48+
BackCommand = ReactiveCommand.Create();
4849
}
4950

5051
public IRepositoryModel SourceRepository { get; private set; }
@@ -55,10 +56,14 @@ IRepositoryForkService repositoryForkService
5556

5657
public IReactiveCommand<Repository> CreateFork { get; }
5758

59+
public IReactiveCommand<object> BackCommand { get; }
60+
5861
public string Title => Resources.ForkRepositoryTitle;
5962

6063
public IObservable<object> Done => CreateFork.Where(repository => repository != null);
6164

65+
public IObservable<object> Back => BackCommand.AsObservable();
66+
6267
public async Task InitializeAsync(ILocalRepositoryModel sourceRepository, IAccount destinationAccount, IConnection connection)
6368
{
6469
var modelService = await modelServiceFactory.CreateAsync(connection);
@@ -125,21 +130,22 @@ public bool AddUpstream
125130
set { this.RaiseAndSetIfChanged(ref addUpstream, value); }
126131
}
127132

128-
bool canResetMasterTracking = true;
133+
bool canResetMasterTracking;
129134
public bool CanResetMasterTracking
130135
{
131136
get { return canResetMasterTracking; }
132137
private set { this.RaiseAndSetIfChanged(ref canResetMasterTracking, value); }
133138
}
134139

135-
bool resetMasterTracking = true;
140+
bool resetMasterTracking;
136141
public bool ResetMasterTracking
137142
{
138143
get { return resetMasterTracking; }
139144
set { this.RaiseAndSetIfChanged(ref resetMasterTracking, value); }
140145
}
141146

142147
string error = null;
148+
143149
public string Error
144150
{
145151
get { return error; }

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ void BuildAccounts(IReadOnlyList<IAccount> accessibleAccounts, ILocalRepositoryM
108108

109109
Accounts = readOnlyList.Where(arg => arg.Fork == null).Select(arg => arg.Account).ToList();
110110
ExistingForks = readOnlyList.Where(arg => arg.Fork != null).Select(arg => arg.Fork).ToList();
111+
112+
// HACK: Our avatar cache only provides avatars in a very small size, but we want to
113+
// display them 100x100 in the Fork view. For now, wse the AvatarUrl directly to get
114+
// the avatar, appending "s=100" to the URL to get the correct size.
115+
foreach (Account account in Accounts)
116+
{
117+
account.AvatarUrl += "&s=100";
118+
}
111119
}
112120
}
113121
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public ForkRepositoryViewModel(
3333

3434
selectPage.SwitchOrigin.Subscribe(x => ShowSwitchRepositoryPath((IRemoteRepositoryModel)x));
3535
selectPage.Done.Subscribe(x => ShowExecutePage((IAccount)x).Forget());
36+
executePage.Back.Subscribe(x => ShowSelectPage().Forget());
3637
}
3738

3839
public ILocalRepositoryModel Repository { get; private set; }
@@ -47,7 +48,12 @@ public async Task InitializeAsync(ILocalRepositoryModel repository, IConnection
4748
{
4849
Repository = repository;
4950
Connection = connection;
50-
await selectPage.InitializeAsync(repository, connection);
51+
await ShowSelectPage();
52+
}
53+
54+
async Task ShowSelectPage()
55+
{
56+
await selectPage.InitializeAsync(Repository, Connection);
5157
Content = selectPage;
5258
}
5359

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using GitHub.Services;
1313
using ReactiveUI;
1414
using Serilog;
15+
using static System.FormattableString;
1516

1617
namespace GitHub.ViewModels.GitHubPane
1718
{
@@ -71,6 +72,8 @@ public PullRequestReviewAuthoringViewModel(
7172
hasBodyOrComments,
7273
_ => DoSubmit(Octokit.PullRequestReviewEvent.RequestChanges));
7374
Cancel = ReactiveCommand.CreateAsyncTask(DoCancel);
75+
NavigateToPullRequest = ReactiveCommand.Create().OnExecuteCompleted(_ =>
76+
NavigateTo(Invariant($"{LocalRepository.Owner}/{LocalRepository.Name}/pull/{PullRequestModel.Number}")));
7477
}
7578

7679
/// <inheritdoc/>

src/GitHub.Exports.Reactive/ViewModels/Dialog/IForkRepositoryExecuteViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public interface IForkRepositoryExecuteViewModel : IDialogContentViewModel
2323
/// </summary>
2424
IReactiveCommand<Repository> CreateFork { get; }
2525

26+
IReactiveCommand<object> BackCommand { get; }
27+
2628
bool ResetMasterTracking { get; set; }
2729

2830
bool AddUpstream { get; set; }
@@ -34,6 +36,7 @@ public interface IForkRepositoryExecuteViewModel : IDialogContentViewModel
3436
bool CanResetMasterTracking { get; }
3537

3638
string Error { get; }
39+
IObservable<object> Back { get; }
3740

3841
/// <summary>
3942
/// Initializes the view model.

src/GitHub.Exports/Exports/ExportForProcess.cs renamed to src/GitHub.Exports/Exports/ExportForProcessAttribute.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.ComponentModel.Composition;
45

56
namespace GitHub.Exports
@@ -11,24 +12,32 @@ namespace GitHub.Exports
1112
/// This attribute is used to mark exports that mustn't be loaded into Blend.
1213
/// See: https://github.com/github/VisualStudio/pull/1055
1314
/// </remarks>
15+
[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Extended by ExportForVisualStudioProcessAttribute")]
1416
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
15-
public sealed class ExportForProcessAttribute : ExportAttribute
17+
public class ExportForProcessAttribute : ExportAttribute
1618
{
19+
// Unique name for exports that have been disabled
20+
const string DisabledContractName = "GitHub.Disabled";
21+
1722
/// <summary>
1823
/// Define an export that is only exposed in a specific named process.
1924
/// </summary>
20-
/// <param name="contractType">The contract type to expose.</param>
2125
/// <param name="processName">Name of the process to expose export from (e.g. 'devenv').</param>
22-
public ExportForProcessAttribute(Type contractType, string processName) : base(ExportForProcess(contractType, processName))
26+
/// <param name="contractType">The contract type to expose.</param>
27+
public ExportForProcessAttribute(string processName, Type contractType = null) :
28+
base(ContractNameForProcess(processName), contractType)
2329
{
2430
ProcessName = processName;
2531
}
2632

27-
static Type ExportForProcess(Type contractType, string processName)
33+
static string ContractNameForProcess(string processName)
2834
{
29-
return Process.GetCurrentProcess().ProcessName == processName ? contractType : null;
35+
var enabled = IsProcess(processName);
36+
return enabled ? null : DisabledContractName;
3037
}
3138

39+
public static bool IsProcess(string processName) => Process.GetCurrentProcess().ProcessName == processName;
40+
3241
/// <summary>
3342
/// The process name export will be exposed in.
3443
/// </summary>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
3+
namespace GitHub.Exports
4+
{
5+
/// <summary>
6+
/// Only expose export when executing in Visual Studio (devenv) process.
7+
/// </summary>
8+
/// <remarks>
9+
/// This attribute is used to mark exports that mustn't be loaded into Blend.
10+
/// See: https://github.com/github/VisualStudio/pull/1055
11+
/// </remarks>
12+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
13+
public sealed class ExportForVisualStudioProcessAttribute : ExportForProcessAttribute
14+
{
15+
const string VisualStudioProcessName = "devenv";
16+
17+
/// <summary>
18+
/// Define an export that is only exposed in a Visual Studio (devenv) process.
19+
/// </summary>
20+
/// <param name="contractType">The contract type to expose.</param>
21+
public ExportForVisualStudioProcessAttribute(Type contractType = null) :
22+
base(VisualStudioProcessName, contractType)
23+
{
24+
}
25+
26+
public static bool IsVisualStudioProcess() => IsProcess(VisualStudioProcessName);
27+
}
28+
}

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@
159159
<Compile Include="Commands\IGoToSolutionOrPullRequestFileCommand.cs" />
160160
<Compile Include="Commands\IVsCommand.cs" />
161161
<Compile Include="Commands\IVsCommandBase.cs" />
162-
<Compile Include="Exports\ExportForProcess.cs" />
162+
<Compile Include="Exports\ExportForVisualStudioProcessAttribute.cs" />
163+
<Compile Include="Exports\ExportForProcessAttribute.cs" />
163164
<Compile Include="Extensions\ConnectionManagerExtensions.cs" />
164165
<Compile Include="GitHubLogicException.cs" />
165166
<Compile Include="Models\CommitMessage.cs" />

src/GitHub.Exports/Models/UsageModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ public class MeasuresModel
7373
public int NumberOfGitHubConnectSectionClones { get; set; }
7474
public int NumberOfShowRepoForkDialogClicks { get; set; }
7575
public int NumberOfReposForked { get; set; }
76-
public int NumberOfOriginsUpdatedWhenForkingRepo { get; set; }
77-
public int NumberOfUpstreamsAddedWhenForkingRepo { get; set; }
78-
public int NumberOfTrackMasterUpstreamWhenForkingRepo { get; set; }
7976
public int ExecuteGoToSolutionOrPullRequestFileCommand { get; set; }
8077
public int NumberOfPRDetailsNavigateToEditor { get; set; } // Should rename to NumberOfNavigateToEditor
8178
public int NumberOfNavigateToPullRequestFileDiff { get; set; }

src/GitHub.InlineReviews/InlineReviewsPackage.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
using System.ComponentModel.Design;
33
using System.Runtime.InteropServices;
44
using System.Threading;
5+
using GitHub.Exports;
6+
using GitHub.Logging;
57
using GitHub.Commands;
68
using GitHub.Services.Vssdk.Commands;
79
using GitHub.VisualStudio;
810
using Microsoft.VisualStudio.ComponentModelHost;
911
using Microsoft.VisualStudio.Shell;
1012
using Microsoft.VisualStudio.Threading;
13+
using Serilog;
1114
using Task = System.Threading.Tasks.Task;
1215

1316
namespace GitHub.InlineReviews
@@ -18,6 +21,8 @@ namespace GitHub.InlineReviews
1821
[ProvideMenuResource("Menus.ctmenu", 1)]
1922
public class InlineReviewsPackage : AsyncPackage
2023
{
24+
static readonly ILogger log = LogManager.ForContext<InlineReviewsPackage>();
25+
2126
protected override async Task InitializeAsync(
2227
CancellationToken cancellationToken,
2328
IProgress<ServiceProgressData> progress)
@@ -33,6 +38,12 @@ protected override async Task InitializeAsync(
3338

3439
async Task InitializeMenus()
3540
{
41+
if (!ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
42+
{
43+
log.Warning("Don't initialize menus for non-Visual Studio process");
44+
return;
45+
}
46+
3647
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
3748
var exports = componentModel.DefaultExportProvider;
3849
var commands = new IVsCommandBase[]

0 commit comments

Comments
 (0)