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

Commit d5ed33d

Browse files
authored
Merge branch 'master' into fixes/1565-comments-margin-toggle
2 parents d0dd283 + 3da6922 commit d5ed33d

File tree

54 files changed

+1518
-9
lines changed

Some content is hidden

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

54 files changed

+1518
-9
lines changed

GitHubVS.sln

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ Global
221221
{E4ED0537-D1D9-44B6-9212-3096D7C3F7A1}.Release|Any CPU.Build.0 = Release|Any CPU
222222
{E4ED0537-D1D9-44B6-9212-3096D7C3F7A1}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
223223
{E4ED0537-D1D9-44B6-9212-3096D7C3F7A1}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
224-
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Debug|Any CPU.ActiveCfg = Release|Any CPU
225-
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Debug|Any CPU.Build.0 = Release|Any CPU
224+
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
225+
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
226226
{08DD4305-7787-4823-A53F-4D0F725A07F3}.DebugCodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU
227227
{08DD4305-7787-4823-A53F-4D0F725A07F3}.DebugCodeAnalysis|Any CPU.Build.0 = Release|Any CPU
228228
{08DD4305-7787-4823-A53F-4D0F725A07F3}.DebugWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
@@ -468,4 +468,7 @@ Global
468468
{14FDEE91-7301-4247-846C-049647BF8E99} = {C2D88962-BD6B-4F11-B914-535B38377962}
469469
{09313E65-7ADB-48C1-AD3A-572020C5BDCB} = {C2D88962-BD6B-4F11-B914-535B38377962}
470470
EndGlobalSection
471+
GlobalSection(ExtensibilityGlobals) = postSolution
472+
SolutionGuid = {556014CF-5B35-4CE5-B3EF-6AB0007001AC}
473+
EndGlobalSection
471474
EndGlobal

script

src/GitHub.App/Api/ApiClient.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ public IObservable<Repository> CreateRepository(NewRepository repository, string
4848
return (isUser ? client.Create(repository) : client.Create(login, repository));
4949
}
5050

51+
public IObservable<Repository> ForkRepository(string owner, string name, NewRepositoryFork repository)
52+
{
53+
Guard.ArgumentNotEmptyString(owner, nameof(owner));
54+
Guard.ArgumentNotEmptyString(name, nameof(name));
55+
Guard.ArgumentNotNull(repository, nameof(repository));
56+
57+
var client = gitHubClient.Repository.Forks;
58+
59+
return client.Create(owner, name, repository);
60+
}
61+
5162
public IObservable<PullRequestReview> PostPullRequestReview(
5263
string owner,
5364
string name,
@@ -104,6 +115,11 @@ public IObservable<Gist> CreateGist(NewGist newGist)
104115
return gitHubClient.Gist.Create(newGist);
105116
}
106117

118+
public IObservable<Repository> GetForks(string owner, string name)
119+
{
120+
return gitHubClient.Repository.Forks.GetAll(owner, name);
121+
}
122+
107123
public IObservable<User> GetUser()
108124
{
109125
return gitHubClient.User.Current();

src/GitHub.App/GitHub.App.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,22 @@
211211
<Compile Include="Models\IssueCommentModel.cs" />
212212
<Compile Include="Models\PullRequestReviewCommentModel.cs" />
213213
<Compile Include="Models\PullRequestDetailArgument.cs" />
214+
<Compile Include="SampleData\ForkRepositoryExecuteViewModelDesigner.cs" />
215+
<Compile Include="SampleData\ForkRepositorySelectViewModelDesigner.cs" />
214216
<Compile Include="Models\PullRequestReviewModel.cs" />
217+
<Compile Include="SampleData\ForkRepositorySwitchViewModelDesigner.cs" />
215218
<Compile Include="SampleData\PullRequestFilesViewModelDesigner.cs" />
216219
<Compile Include="SampleData\PullRequestReviewAuthoringViewModelDesigner.cs" />
217220
<Compile Include="SampleData\PullRequestReviewFileCommentViewModelDesigner.cs" />
218221
<Compile Include="SampleData\PullRequestReviewViewModelDesigner.cs" />
219222
<Compile Include="SampleData\PullRequestUserReviewsViewModelDesigner.cs" />
220223
<Compile Include="Services\EnterpriseCapabilitiesService.cs" />
221224
<Compile Include="Services\GlobalConnection.cs" />
225+
<Compile Include="Services\RepositoryForkService.cs" />
226+
<Compile Include="ViewModels\Dialog\ForkRepositoryExecuteViewModel.cs" />
227+
<Compile Include="ViewModels\Dialog\ForkRepositorySwitchViewModel.cs" />
228+
<Compile Include="ViewModels\Dialog\ForkRepositoryViewModel.cs" />
229+
<Compile Include="ViewModels\Dialog\ForkRepositorySelectViewModel.cs" />
222230
<Compile Include="Services\PullRequestEditorService.cs" />
223231
<Compile Include="Services\TeamExplorerContext.cs" />
224232
<Compile Include="Services\OAuthCallbackListener.cs" />
@@ -396,6 +404,7 @@
396404
<EmbeddedResource Include="Resources.resx">
397405
<Generator>PublicResXFileCodeGenerator</Generator>
398406
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
407+
<SubType>Designer</SubType>
399408
</EmbeddedResource>
400409
</ItemGroup>
401410
<ItemGroup>

src/GitHub.App/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.App/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,10 @@ https://git-scm.com/download/win</value>
315315
<data name="NavigateToEditorNotCheckedOutStatusMessage" xml:space="preserve">
316316
<value>Press Enter to navigate to Editor (PR branch must be checked out)</value>
317317
</data>
318+
<data name="ForkRepositoryTitle" xml:space="preserve">
319+
<value>Fork Repository</value>
320+
</data>
321+
<data name="SwitchOriginTitle" xml:space="preserve">
322+
<value>Switch Origin</value>
323+
</data>
318324
</root>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using GitHub.Models;
4+
using GitHub.ViewModels;
5+
using GitHub.ViewModels.Dialog;
6+
using Octokit;
7+
using ReactiveUI;
8+
using IConnection = GitHub.Models.IConnection;
9+
10+
namespace GitHub.SampleData
11+
{
12+
public class ForkRepositoryExecuteViewModelDesigner : ViewModelBase, IForkRepositoryExecuteViewModel
13+
{
14+
public ForkRepositoryExecuteViewModelDesigner()
15+
{
16+
SourceRepository = new RemoteRepositoryModelDesigner
17+
{
18+
Owner = "github",
19+
Name = "VisualStudio",
20+
CloneUrl = "https://github.com/github/VisualStudio",
21+
};
22+
DestinationRepository = new RemoteRepositoryModelDesigner
23+
{
24+
Owner = "user",
25+
Name = "VisualStudio",
26+
CloneUrl = "https://github.com/user/VisualStudio",
27+
};
28+
DestinationAccount = new AccountDesigner();
29+
}
30+
31+
public IObservable<object> Done => null;
32+
33+
public string Title => null;
34+
35+
public IRepositoryModel SourceRepository { get; set; }
36+
37+
public IRepositoryModel DestinationRepository { get; set; }
38+
39+
public IAccount DestinationAccount { get; }
40+
41+
public IReactiveCommand<Repository> CreateFork => null;
42+
43+
public bool ResetMasterTracking { get; set; } = true;
44+
45+
public bool AddUpstream { get; set; } = true;
46+
47+
public bool UpdateOrigin { get; set; } = true;
48+
49+
public bool CanAddUpstream => UpdateOrigin;
50+
51+
public bool CanResetMasterTracking => UpdateOrigin && AddUpstream;
52+
53+
public string Error { get; } = "I AM ERROR";
54+
55+
public Task InitializeAsync(ILocalRepositoryModel sourceRepository, IAccount destinationAccount, IConnection connection)
56+
{
57+
return Task.CompletedTask;
58+
}
59+
}
60+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using GitHub.Models;
5+
using GitHub.ViewModels;
6+
using GitHub.ViewModels.Dialog;
7+
using ReactiveUI;
8+
9+
namespace GitHub.SampleData
10+
{
11+
public class ForkRepositorySelectViewModelDesigner : ViewModelBase, IForkRepositorySelectViewModel
12+
{
13+
public ForkRepositorySelectViewModelDesigner()
14+
{
15+
Accounts = new[]
16+
{
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" },
22+
};
23+
24+
ExistingForks = new[]
25+
{
26+
new RemoteRepositoryModelDesigner { Owner = "MyOrg5", Name = "MyRepo" },
27+
new RemoteRepositoryModelDesigner { Owner = "MyOrg6", Name = "MyRepo" },
28+
};
29+
}
30+
31+
public IReadOnlyList<IAccount> Accounts { get; set; }
32+
33+
public IObservable<object> Done => null;
34+
35+
public IReadOnlyList<IRemoteRepositoryModel> ExistingForks { get; set; }
36+
37+
public bool IsLoading { get; set; }
38+
39+
public string Title => null;
40+
41+
public ReactiveCommand<object> SelectedAccount => null;
42+
43+
public ReactiveCommand<object> SwitchOrigin => null;
44+
45+
public Task InitializeAsync(ILocalRepositoryModel repository, IConnection connection)
46+
{
47+
return Task.CompletedTask;
48+
}
49+
}
50+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using GitHub.Models;
3+
using GitHub.ViewModels;
4+
using GitHub.ViewModels.Dialog;
5+
using ReactiveUI;
6+
7+
namespace GitHub.SampleData
8+
{
9+
public class ForkRepositorySwitchViewModelDesigner : ViewModelBase, IForkRepositorySwitchViewModel
10+
{
11+
public ForkRepositorySwitchViewModelDesigner()
12+
{
13+
SourceRepository = new RemoteRepositoryModelDesigner
14+
{
15+
Owner = "github",
16+
Name = "VisualStudio",
17+
CloneUrl = "https://github.com/github/VisualStudio",
18+
};
19+
DestinationRepository = new RemoteRepositoryModelDesigner
20+
{
21+
Owner = "user",
22+
Name = "VisualStudio",
23+
CloneUrl = "https://github.com/user/VisualStudio",
24+
};
25+
}
26+
27+
public string Title => null;
28+
29+
public IObservable<object> Done => null;
30+
31+
public IRepositoryModel SourceRepository { get; }
32+
33+
public IRepositoryModel DestinationRepository { get; }
34+
35+
public IReactiveCommand<object> SwitchFork => null;
36+
37+
public bool ResetMasterTracking { get; set; } = true;
38+
39+
public bool AddUpstream { get; set; } = true;
40+
41+
public bool UpdateOrigin { get; set; } = true;
42+
43+
public void Initialize(ILocalRepositoryModel sourceRepository, IRemoteRepositoryModel remoteRepository)
44+
{
45+
}
46+
}
47+
}

src/GitHub.App/Services/DialogService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,15 @@ public async Task<IConnection> ShowLoginDialog()
7171
var viewModel = factory.CreateViewModel<ILoginViewModel>();
7272
return (IConnection)await showDialog.Show(viewModel);
7373
}
74+
75+
public async Task ShowForkDialog(ILocalRepositoryModel repository, IConnection connection)
76+
{
77+
Guard.ArgumentNotNull(repository, nameof(repository));
78+
Guard.ArgumentNotNull(connection, nameof(connection));
79+
80+
var viewModel = factory.CreateViewModel<IForkRepositoryViewModel>();
81+
await viewModel.InitializeAsync(repository, connection);
82+
await showDialog.Show(viewModel);
83+
}
7484
}
7585
}

0 commit comments

Comments
 (0)