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

Commit d0d36e2

Browse files
authored
Merge branch 'refactor/clone' into refactor/clone-include-owner-in-path
2 parents 5cd8a91 + f5369ba commit d0d36e2

File tree

12 files changed

+115
-4
lines changed

12 files changed

+115
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ $RECYCLE.BIN/
232232
*.msm
233233
*.msp
234234

235+
#OpenCover output
236+
coverage.xml
237+
235238
AkavacheSqliteLinkerOverride.cs
236239
NuGetBuild
237240
WiX.Toolset.DummyFile.txt

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ on_success:
2929
if ($full_build) {
3030
script\Sign-Package -AppVeyor
3131
}
32+
on_finish:
33+
- ps: scripts\Run-CodeCoverage.ps1 -AppVeyor -Configuration:Release

scripts/Run-CodeCoverage.ps1

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<#
2+
.SYNOPSIS
3+
Runs NUnit
4+
#>
5+
6+
[CmdletBinding()]
7+
Param(
8+
[string]
9+
$Configuration
10+
,
11+
[switch]
12+
$AppVeyor = $false
13+
)
14+
15+
$scriptsDirectory = $PSScriptRoot
16+
$rootDirectory = Split-Path ($scriptsDirectory)
17+
. $scriptsDirectory\modules.ps1 | out-null
18+
19+
$nunitDirectory = Join-Path $rootDirectory packages\NUnit.ConsoleRunner.3.7.0\tools
20+
$nunitConsoleRunner = Join-Path $nunitDirectory nunit3-console.exe
21+
22+
$testAssemblies = @(
23+
"test\GitHub.Api.UnitTests\bin\$Configuration\GitHub.Api.UnitTests.dll",
24+
"test\GitHub.App.UnitTests\bin\$Configuration\GitHub.App.UnitTests.dll",
25+
"test\GitHub.Exports.Reactive.UnitTests\bin\$Configuration\GitHub.Exports.Reactive.UnitTests.dll",
26+
"test\GitHub.Exports.UnitTests\bin\$Configuration\GitHub.Exports.UnitTests.dll",
27+
"test\GitHub.Extensions.UnitTests\bin\$Configuration\GitHub.Extensions.UnitTests.dll",
28+
"test\GitHub.InlineReviews.UnitTests\bin\$Configuration\GitHub.InlineReviews.UnitTests.dll",
29+
"test\GitHub.Primitives.UnitTests\bin\$Configuration\GitHub.Primitives.UnitTests.dll",
30+
"test\GitHub.TeamFoundation.UnitTests\bin\$Configuration\GitHub.TeamFoundation.UnitTests.dll",
31+
"test\GitHub.UI.UnitTests\bin\$Configuration\GitHub.UI.UnitTests.dll",
32+
"test\GitHub.VisualStudio.UnitTests\bin\$Configuration\GitHub.VisualStudio.UnitTests.dll",
33+
"test\MetricsTests\MetricsTests\bin\$Configuration\MetricsTests.dll",
34+
"test\TrackingCollectionTests\bin\$Configuration\TrackingCollectionTests.dll"
35+
)
36+
37+
$opencoverTargetArgs = ($testAssemblies -join " ") + " --where \`"cat!=Timings and cat!=CodeCoverageFlake\`" --inprocess --noresult"
38+
39+
$opencoverDirectory = Join-Path $rootDirectory packages\OpenCover.4.6.519\tools
40+
$opencover = Join-Path $opencoverDirectory OpenCover.Console.exe
41+
$opencoverArgs = @(
42+
"-target:`"$nunitConsoleRunner`"",
43+
"-targetargs:`"$opencoverTargetArgs`"",
44+
"-filter:`"+[GitHub*]* -[GitHub*UnitTests]*`"",
45+
"-register:user -output:$rootDirectory\coverage.xml"
46+
) -join " "
47+
48+
$codecovDirectory = Join-Path $rootDirectory packages\Codecov.1.0.5\tools
49+
$codecov = Join-Path $codecovDirectory codecov.exe
50+
$codecovArgs = "-f $rootDirectory\coverage.xml"
51+
52+
& {
53+
Trap {
54+
Write-Output "$Project tests failed"
55+
exit 0
56+
}
57+
58+
Run-Process 600 $opencover $opencoverArgs
59+
60+
if($AppVeyor) {
61+
Run-Process 60 $codecov $codecovArgs
62+
}
63+
64+
if (!$?) {
65+
Write-Output "$Project tests failed"
66+
exit 0
67+
}
68+
}

scripts/modules.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ New-Module -ScriptBlock {
7373
$output += Get-Content $outputPath
7474
$exitCode = $process.ExitCode
7575
} else {
76-
$output += "Tests timed out. Backtrace:"
76+
$output += "Process timed out. Backtrace:"
7777
$output += Get-DotNetStack $process.Id
7878
$exitCode = 9999
7979
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public RepositoryCloneViewModelDesigner()
2323
public IRepositorySelectViewModel GitHubTab { get; }
2424
public IRepositorySelectViewModel EnterpriseTab { get; }
2525
public IRepositoryUrlViewModel UrlTab { get; }
26+
public ReactiveCommand<object> Browse { get; }
2627
public ReactiveCommand<CloneDialogResult> Clone { get; }
2728

2829
public Task InitializeAsync(IConnection connection)

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using GitHub.Models;
1111
using GitHub.Services;
1212
using ReactiveUI;
13+
using Rothko;
1314
using Serilog;
1415

1516
namespace GitHub.ViewModels.Dialog.Clone
@@ -19,6 +20,7 @@ namespace GitHub.ViewModels.Dialog.Clone
1920
public class RepositoryCloneViewModel : ViewModelBase, IRepositoryCloneViewModel
2021
{
2122
static readonly ILogger log = LogManager.ForContext<RepositoryCloneViewModel>();
23+
readonly IOperatingSystem os;
2224
readonly IConnectionManager connectionManager;
2325
readonly IRepositoryCloneService service;
2426
readonly IReadOnlyList<IRepositoryCloneTabViewModel> tabs;
@@ -29,12 +31,14 @@ public class RepositoryCloneViewModel : ViewModelBase, IRepositoryCloneViewModel
2931

3032
[ImportingConstructor]
3133
public RepositoryCloneViewModel(
34+
IOperatingSystem os,
3235
IConnectionManager connectionManager,
3336
IRepositoryCloneService service,
3437
IRepositorySelectViewModel gitHubTab,
3538
IRepositorySelectViewModel enterpriseTab,
3639
IRepositoryUrlViewModel urlTab)
3740
{
41+
this.os = os;
3842
this.connectionManager = connectionManager;
3943
this.service = service;
4044

@@ -61,6 +65,7 @@ public RepositoryCloneViewModel(
6165
(repo, error) => (repo, error))
6266
.Select(x => x.repo != null && x.error == null);
6367

68+
Browse = ReactiveCommand.Create().OnExecuteCompleted(_ => BrowseForDirectory());
6469
Clone = ReactiveCommand.CreateAsyncObservable(
6570
canClone,
6671
_ => repository.Select(x => new CloneDialogResult(Path, x)));
@@ -88,6 +93,8 @@ public int SelectedTabIndex
8893

8994
public IObservable<object> Done => Clone;
9095

96+
public ReactiveCommand<object> Browse { get; }
97+
9198
public ReactiveCommand<CloneDialogResult> Clone { get; }
9299

93100
public async Task InitializeAsync(IConnection connection)
@@ -114,6 +121,24 @@ public async Task InitializeAsync(IConnection connection)
114121
this.WhenAnyValue(x => x.SelectedTabIndex).Subscribe(x => tabs[x].Activate().Forget());
115122
}
116123

124+
void BrowseForDirectory()
125+
{
126+
var result = os.Dialog.BrowseForDirectory(Path, Resources.BrowseForDirectory);
127+
128+
if (result != BrowseDirectoryResult.Failed)
129+
{
130+
var path = result.DirectoryPath;
131+
var selected = tabs[SelectedTabIndex].Repository;
132+
133+
if (selected != null)
134+
{
135+
path = System.IO.Path.Combine(path, selected.Name);
136+
}
137+
138+
Path = path;
139+
}
140+
}
141+
117142
void UpdatePath(IRepositoryModel repository)
118143
{
119144
if (repository != null)

src/GitHub.Exports.Reactive/ViewModels/Dialog/Clone/IRepositoryCloneViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public interface IRepositoryCloneViewModel : IDialogContentViewModel, IConnectio
4242
/// </remarks>
4343
int SelectedTabIndex { get; }
4444

45+
/// <summary>
46+
/// Gets the command executed when the user clicks "Browse".
47+
/// </summary>
48+
ReactiveCommand<object> Browse { get; }
49+
4550
/// <summary>
4651
/// Gets the command executed when the user clicks "Clone".
4752
/// </summary>

src/GitHub.VisualStudio/Views/Dialog/Clone/RepositoryCloneView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Margin="16">
3737
<Label DockPanel.Dock="Left">Local Path</Label>
3838
<Button DockPanel.Dock="Right"
39+
Command="{Binding Browse}"
3940
Style="{DynamicResource GitHubBlueLinkButton}"
4041
VerticalContentAlignment="Center">
4142
Browse

test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using GitHub.ViewModels.Dialog.Clone;
99
using NSubstitute;
1010
using NUnit.Framework;
11+
using Rothko;
1112

1213
namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone
1314
{
@@ -269,19 +270,22 @@ static IRepositoryCloneService CreateRepositoryCloneService()
269270
}
270271

271272
static RepositoryCloneViewModel CreateTarget(
273+
IOperatingSystem os = null,
272274
IConnectionManager connectionManager = null,
273275
IRepositoryCloneService service = null,
274276
IRepositorySelectViewModel gitHubTab = null,
275277
IRepositorySelectViewModel enterpriseTab = null,
276278
IRepositoryUrlViewModel urlTab = null)
277279
{
280+
os = os ?? Substitute.For<IOperatingSystem>();
278281
connectionManager = connectionManager ?? CreateConnectionManager("https://github.com");
279282
service = service ?? CreateRepositoryCloneService();
280283
gitHubTab = gitHubTab ?? CreateSelectViewModel();
281284
enterpriseTab = enterpriseTab ?? CreateSelectViewModel();
282285
urlTab = urlTab ?? Substitute.For<IRepositoryUrlViewModel>();
283286

284287
return new RepositoryCloneViewModel(
288+
os,
285289
connectionManager,
286290
service,
287291
gitHubTab,

test/GitHub.InlineReviews.UnitTests/Services/PullRequestSessionManagerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Line 2
442442
}
443443
}
444444

445-
[Test]
445+
[Test, NUnit.Framework.Category("CodeCoverageFlake")]
446446
public async Task UpdatesInlineCommentThreadsFromEditorContent()
447447
{
448448
var baseContents = @"Line 1
@@ -497,7 +497,7 @@ Line 2
497497
}
498498
}
499499

500-
[Test]
500+
[Test, NUnit.Framework.Category("CodeCoverageFlake")]
501501
public async Task UpdatesReviewCommentWithNewBody()
502502
{
503503
var baseContents = @"Line 1

0 commit comments

Comments
 (0)