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

Commit 0ba59a3

Browse files
authored
Merge branch 'master' into devops/build-on-2019
2 parents e22e364 + dbf983f commit 0ba59a3

File tree

21 files changed

+454
-217
lines changed

21 files changed

+454
-217
lines changed

GitHubVS.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Octokit.GraphQL.Core", "sub
141141
EndProject
142142
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Octokit.GraphQL", "submodules\octokit.graphql.net\Octokit.GraphQL\Octokit.GraphQL.csproj", "{791B408C-0ABC-465B-9EB1-A2422D67F418}"
143143
EndProject
144+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.StartPage.UnitTests", "test\GitHub.StartPage.UnitTests\GitHub.StartPage.UnitTests.csproj", "{B467682B-9F0E-42D8-8A20-1DE78F798793}"
145+
EndProject
144146
Global
145147
GlobalSection(SolutionConfigurationPlatforms) = preSolution
146148
Debug|Any CPU = Debug|Any CPU
@@ -493,6 +495,14 @@ Global
493495
{791B408C-0ABC-465B-9EB1-A2422D67F418}.Release|Any CPU.Build.0 = Release|Any CPU
494496
{791B408C-0ABC-465B-9EB1-A2422D67F418}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
495497
{791B408C-0ABC-465B-9EB1-A2422D67F418}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
498+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
499+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.Debug|Any CPU.Build.0 = Debug|Any CPU
500+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.DebugWithoutVsix|Any CPU.ActiveCfg = Debug|Any CPU
501+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.DebugWithoutVsix|Any CPU.Build.0 = Debug|Any CPU
502+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.Release|Any CPU.ActiveCfg = Release|Any CPU
503+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.Release|Any CPU.Build.0 = Release|Any CPU
504+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
505+
{B467682B-9F0E-42D8-8A20-1DE78F798793}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
496506
EndGlobalSection
497507
GlobalSection(SolutionProperties) = preSolution
498508
HideSolutionNode = FALSE
@@ -527,6 +537,7 @@ Global
527537
{65542DEE-D3BE-4810-B85A-08E970413A21} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
528538
{3321CE72-26ED-4D1E-A8F5-6901FB783007} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AC0}
529539
{791B408C-0ABC-465B-9EB1-A2422D67F418} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AC0}
540+
{B467682B-9F0E-42D8-8A20-1DE78F798793} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
530541
EndGlobalSection
531542
GlobalSection(ExtensibilityGlobals) = postSolution
532543
SolutionGuid = {556014CF-5B35-4CE5-B3EF-6AB0007001AC}

appveyor.yml

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
os: Visual Studio 2017
22
version: '2.8.0.{build}'
33
skip_tags: true
4+
5+
environment:
6+
matrix:
7+
- BUILD_TYPE: normal
8+
49
install:
10+
- choco install --no-progress BCC-MSBuildLog
11+
- choco install --no-progress BCC-Submission
512
- ps: |
613
$full_build = Test-Path env:GHFVS_KEY
14+
$forVSInstaller = $env:BUILD_TYPE -eq "vsinstaller"
15+
$package = $full_build -and ($env:APPVEYOR_PULL_REQUEST_NUMBER -or $forVSInstaller -or $env:BUILD_TYPE -eq "package")
16+
17+
$message = "Building "
18+
if ($package) { $message += "and packaging "}
19+
$message += "version " + $env:APPVEYOR_BUILD_NUMBER + " "
20+
21+
if ($full_build) { $message += "(full build)" } else { $message += "(partial build)" }
22+
if ($forVSInstaller) { $message += " for the VS installer" }
23+
Write-Host $message
24+
725
git submodule init
826
git submodule sync
927
@@ -18,19 +36,29 @@ install:
1836
1937
git submodule update --recursive --force
2038
nuget restore GitHubVS.sln
21-
- choco install --no-progress BCC-MSBuildLog
22-
- choco install --no-progress BCC-Submission
39+
2340
build_script:
24-
- ps: scripts\build.ps1 -AppVeyor -BuildNumber:$env:APPVEYOR_BUILD_NUMBER
41+
- ps: scripts\build.ps1 -AppVeyor -Package:$package -BuildNumber:$env:APPVEYOR_BUILD_NUMBER -ForVSInstaller:$forVSInstaller
42+
2543
test:
2644
categories:
2745
except:
2846
- Timings
47+
2948
on_success:
3049
- ps: |
31-
if ($full_build) {
32-
script\Sign-Package -AppVeyor
50+
if ($package) {
51+
Write-Host "Signing and packaging"
52+
script\Sign-Package -AppVeyor -ForVSInstaller:$forVSInstaller
3353
}
34-
on_finish:
35-
- IF NOT "%BCC_TOKEN%x"=="x" BCCMSBuildLog --cloneRoot "%APPVEYOR_BUILD_FOLDER%" --input output.binlog --output checkrun.json --ownerRepo %APPVEYOR_REPO_NAME% --hash %APPVEYOR_REPO_COMMIT%
36-
- IF NOT "%BCC_TOKEN%x"=="x" BCCSubmission -h %APPVEYOR_REPO_COMMIT% -i checkrun.json -t %BCC_TOKEN%
54+
55+
for:
56+
-
57+
branches:
58+
only:
59+
- /releases/.*-vsinstaller/
60+
- master
61+
environment:
62+
matrix:
63+
- BUILD_TYPE: package
64+
- BUILD_TYPE: vsinstaller

scripts/build.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ Param(
3838
,
3939
[switch]
4040
$Trace = $false
41+
,
42+
[switch]
43+
$ForVSInstaller = $false
44+
4145
)
4246

4347
Set-StrictMode -Version Latest
@@ -53,6 +57,10 @@ Vsix | out-null
5357

5458
Push-Location $rootDirectory
5559

60+
if ($Package -and $BuildNumber -gt -1) {
61+
$BumpVersion = $true
62+
}
63+
5664
if ($UpdateSubmodules) {
5765
Update-Submodules
5866
}
@@ -61,13 +69,6 @@ if ($Clean) {
6169
Clean-WorkingTree
6270
}
6371

64-
$fullBuild = Test-Path env:GHFVS_KEY
65-
$publishable = $fullBuild -and $AppVeyor -and ($env:APPVEYOR_PULL_REQUEST_NUMBER -or $env:APPVEYOR_REPO_BRANCH -eq "master")
66-
if ($publishable) { #forcing a deploy flag for CI
67-
$Package = $true
68-
$BumpVersion = $true
69-
}
70-
7172
if ($BumpVersion) {
7273
Write-Output "Bumping the version"
7374
Bump-Version -BumpBuild -BuildNumber:$BuildNumber
@@ -79,6 +80,6 @@ if ($Package) {
7980
Write-Output "Building GitHub for Visual Studio"
8081
}
8182

82-
Build-Solution GitHubVs.sln "Build" $config -Deploy:$Package
83+
Build-Solution GitHubVs.sln "Build" $config -Deploy:$Package -ForVSInstaller:$ForVSInstaller
8384

8485
Pop-Location

scripts/modules.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ New-Module -ScriptBlock {
114114
$msbuild
115115
}
116116

117-
function Build-Solution([string]$solution, [string]$target, [string]$configuration, [switch]$ForVSInstaller, [bool]$Deploy = $false) {
117+
function Build-Solution([string]$solution, [string]$target, [string]$configuration, [switch]$ForVSInstaller = $false, [bool]$Deploy = $false) {
118118
$msbuild = Find-MSBuild
119119

120120
Run-Command -Fatal { & $nuget restore $solution -NonInteractive -Verbosity detailed -MSBuildPath (Split-Path -parent $msbuild) }
@@ -185,7 +185,7 @@ New-Module -ScriptBlock {
185185

186186
New-Module -ScriptBlock {
187187
function Write-Manifest([string]$directory) {
188-
Add-Type -Path (Join-Path $rootDirectory packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll)
188+
Add-Type -Path (Join-Path $rootDirectory build\Release\Newtonsoft.Json.dll)
189189

190190
$manifest = @{
191191
NewestExtension = @{

scripts/test.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ if (!$?) {
9797
$exitcode = 11
9898
}
9999

100+
Write-Output "Running GitHub.StartPage.UnitTests..."
101+
Run-NUnit test GitHub.StartPage.UnitTests $TimeoutDuration $config
102+
if (!$?) {
103+
$exitcode = 12
104+
}
105+
100106
if ($exitcode -ne 0) {
101107
$host.SetShouldExit($exitcode)
102108
}

src/GitHub.App/SampleData/Dialog/Clone/RepositoryCloneViewModelDesigner.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Reactive;
33
using System.Threading.Tasks;
44
using GitHub.Models;
5+
using GitHub.Primitives;
56
using GitHub.ViewModels;
67
using GitHub.ViewModels.Dialog.Clone;
78
using ReactiveUI;
@@ -17,13 +18,13 @@ public RepositoryCloneViewModelDesigner()
1718
}
1819

1920
public string Path { get; set; }
21+
public UriString Url { get; set; }
2022
public string PathWarning { get; set; }
2123
public int SelectedTabIndex { get; set; }
2224
public string Title => null;
2325
public IObservable<object> Done => null;
2426
public IRepositorySelectViewModel GitHubTab { get; }
2527
public IRepositorySelectViewModel EnterpriseTab { get; }
26-
public IRepositoryUrlViewModel UrlTab { get; }
2728
public ReactiveCommand<Unit, Unit> Browse { get; }
2829
public ReactiveCommand<Unit, CloneDialogResult> Clone { get; }
2930

src/GitHub.App/Services/DialogService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task<CloneDialogResult> ShowCloneDialog(IConnection connection, str
5151
var viewModel = factory.CreateViewModel<IRepositoryCloneViewModel>();
5252
if (url != null)
5353
{
54-
viewModel.UrlTab.Url = url;
54+
viewModel.Url = url;
5555
}
5656

5757
if (connection != null)

src/GitHub.App/ViewModels/Dialog/Clone/RepositoryCloneViewModel.cs

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using GitHub.Extensions;
1010
using GitHub.Logging;
1111
using GitHub.Models;
12+
using GitHub.Primitives;
1213
using GitHub.Services;
1314
using ReactiveUI;
1415
using Rothko;
@@ -20,15 +21,14 @@ namespace GitHub.ViewModels.Dialog.Clone
2021
[PartCreationPolicy(CreationPolicy.NonShared)]
2122
public class RepositoryCloneViewModel : ViewModelBase, IRepositoryCloneViewModel
2223
{
23-
static readonly ILogger log = LogManager.ForContext<RepositoryCloneViewModel>();
2424
readonly IOperatingSystem os;
2525
readonly IConnectionManager connectionManager;
2626
readonly IRepositoryCloneService service;
2727
readonly IGitService gitService;
28-
readonly IUsageService usageService;
2928
readonly IUsageTracker usageTracker;
3029
readonly IReadOnlyList<IRepositoryCloneTabViewModel> tabs;
3130
string path;
31+
UriString url;
3232
RepositoryModel previousRepository;
3333
ObservableAsPropertyHelper<string> pathWarning;
3434
int selectedTabIndex;
@@ -39,23 +39,19 @@ public RepositoryCloneViewModel(
3939
IConnectionManager connectionManager,
4040
IRepositoryCloneService service,
4141
IGitService gitService,
42-
IUsageService usageService,
4342
IUsageTracker usageTracker,
4443
IRepositorySelectViewModel gitHubTab,
45-
IRepositorySelectViewModel enterpriseTab,
46-
IRepositoryUrlViewModel urlTab)
44+
IRepositorySelectViewModel enterpriseTab)
4745
{
4846
this.os = os;
4947
this.connectionManager = connectionManager;
5048
this.service = service;
5149
this.gitService = gitService;
52-
this.usageService = usageService;
5350
this.usageTracker = usageTracker;
5451

5552
GitHubTab = gitHubTab;
5653
EnterpriseTab = enterpriseTab;
57-
UrlTab = urlTab;
58-
tabs = new IRepositoryCloneTabViewModel[] { GitHubTab, EnterpriseTab, UrlTab };
54+
tabs = new IRepositoryCloneTabViewModel[] { GitHubTab, EnterpriseTab };
5955

6056
var repository = this.WhenAnyValue(x => x.SelectedTabIndex)
6157
.SelectMany(x => tabs[x].WhenAnyValue(tab => tab.Repository));
@@ -88,14 +84,19 @@ public RepositoryCloneViewModel(
8884

8985
public IRepositorySelectViewModel GitHubTab { get; }
9086
public IRepositorySelectViewModel EnterpriseTab { get; }
91-
public IRepositoryUrlViewModel UrlTab { get; }
9287

9388
public string Path
9489
{
9590
get => path;
9691
set => this.RaiseAndSetIfChanged(ref path, value);
9792
}
9893

94+
public UriString Url
95+
{
96+
get => url;
97+
set => this.RaiseAndSetIfChanged(ref url, value);
98+
}
99+
99100
public string PathWarning => pathWarning.Value;
100101

101102
public int SelectedTabIndex
@@ -135,26 +136,21 @@ public async Task InitializeAsync(IConnection connection)
135136
SelectedTabIndex = 1;
136137
}
137138

138-
this.WhenAnyValue(x => x.SelectedTabIndex).Subscribe(x => tabs[x].Activate().Forget());
139-
140-
// When a clipboard URL has been set, show the URL tab by default
141-
if (!string.IsNullOrEmpty(UrlTab.Url))
139+
if (Url?.Host is string host && HostAddress.Create(host) is HostAddress hostAddress)
142140
{
143-
SelectedTabIndex = 2;
141+
if (hostAddress == gitHubConnection?.HostAddress)
142+
{
143+
GitHubTab.Filter = Url;
144+
SelectedTabIndex = 0;
145+
}
146+
else if (hostAddress == enterpriseConnection?.HostAddress)
147+
{
148+
EnterpriseTab.Filter = Url;
149+
SelectedTabIndex = 1;
150+
}
144151
}
145152

146-
switch (SelectedTabIndex)
147-
{
148-
case 0:
149-
usageTracker.IncrementCounter(model => model.NumberOfCloneViewGitHubTab).Forget();
150-
break;
151-
case 1:
152-
usageTracker.IncrementCounter(model => model.NumberOfCloneViewEnterpriseTab).Forget();
153-
break;
154-
case 2:
155-
usageTracker.IncrementCounter(model => model.NumberOfCloneViewUrlTab).Forget();
156-
break;
157-
}
153+
this.WhenAnyValue(x => x.SelectedTabIndex).Subscribe(x => tabs[x].Activate().Forget());
158154
}
159155

160156
void BrowseForDirectory()

src/GitHub.App/ViewModels/Dialog/Clone/RepositorySelectViewModel.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Reactive.Linq;
88
using System.Threading.Tasks;
99
using System.Windows.Data;
10+
using GitHub.Exports;
1011
using GitHub.Extensions;
1112
using GitHub.Logging;
1213
using GitHub.Models;
@@ -23,6 +24,7 @@ public class RepositorySelectViewModel : ViewModelBase, IRepositorySelectViewMod
2324
{
2425
static readonly ILogger log = LogManager.ForContext<RepositorySelectViewModel>();
2526
readonly IRepositoryCloneService service;
27+
readonly IGitHubContextService gitHubContextService;
2628
IConnection connection;
2729
Exception error;
2830
string filter;
@@ -35,15 +37,25 @@ public class RepositorySelectViewModel : ViewModelBase, IRepositorySelectViewMod
3537
IRepositoryItemViewModel selectedItem;
3638

3739
[ImportingConstructor]
38-
public RepositorySelectViewModel(IRepositoryCloneService service)
40+
public RepositorySelectViewModel(IRepositoryCloneService service, IGitHubContextService gitHubContextService)
3941
{
4042
Guard.ArgumentNotNull(service, nameof(service));
43+
Guard.ArgumentNotNull(service, nameof(gitHubContextService));
4144

4245
this.service = service;
46+
this.gitHubContextService = gitHubContextService;
4347

44-
repository = this.WhenAnyValue(x => x.SelectedItem)
45-
.Select(CreateRepository)
48+
var selectedRepository = this.WhenAnyValue(x => x.SelectedItem)
49+
.Select(CreateRepository);
50+
51+
var filterRepository = this.WhenAnyValue(x => x.Filter)
52+
.Select(f => gitHubContextService.FindContextFromUrl(f))
53+
.Select(CreateRepository);
54+
55+
repository = selectedRepository
56+
.Merge(filterRepository)
4657
.ToProperty(this, x => x.Repository);
58+
4759
this.WhenAnyValue(x => x.Filter).Subscribe(_ => ItemsView?.Refresh());
4860
}
4961

@@ -166,7 +178,14 @@ bool FilterItem(object obj)
166178
{
167179
if (obj is IRepositoryItemViewModel item && !string.IsNullOrWhiteSpace(Filter))
168180
{
169-
return item.Caption.Contains(Filter, StringComparison.CurrentCultureIgnoreCase);
181+
var urlString = item.Url.ToString();
182+
var urlStringWithGit = urlString + ".git";
183+
var urlStringWithSlash = urlString + "/";
184+
return
185+
item.Caption.Contains(Filter, StringComparison.CurrentCultureIgnoreCase) ||
186+
urlString.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
187+
urlStringWithGit.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
188+
urlStringWithSlash.Contains(Filter, StringComparison.OrdinalIgnoreCase);
170189
}
171190

172191
return true;
@@ -178,5 +197,17 @@ RepositoryModel CreateRepository(IRepositoryItemViewModel item)
178197
new RepositoryModel(item.Name, UriString.ToUriString(item.Url)) :
179198
null;
180199
}
200+
201+
RepositoryModel CreateRepository(GitHubContext context)
202+
{
203+
switch (context?.LinkType)
204+
{
205+
case LinkType.Repository:
206+
case LinkType.Blob:
207+
return new RepositoryModel(context.RepositoryName, context.Url);
208+
}
209+
210+
return null;
211+
}
181212
}
182213
}

0 commit comments

Comments
 (0)