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

Commit fe2a04f

Browse files
authored
Merge branch 'master' into fixes/2187-unify-repository-list-tabs
2 parents dbbaa8d + fced2fe commit fe2a04f

File tree

9 files changed

+63
-22
lines changed

9 files changed

+63
-22
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Official builds of this extension are available at [the official website](https:
2222
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/github-visual-studio/localized.svg)](https://crowdin.com/project/github-visual-studio)
2323
[![codecov](https://codecov.io/gh/GitHub/VisualStudio/branch/master/graph/badge.svg)](https://codecov.io/gh/GitHub/VisualStudio)
2424

25-
[![Join the chat at freenode:github-vs](https://img.shields.io/badge/irc-freenode:%20%23github--vs-blue.svg)](http://webchat.freenode.net/?channels=%23github-vs) [![Join the chat at https://gitter.im/github/VisualStudio](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/github/VisualStudio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
25+
[![Follow GitHub for Visual Studio](https://img.shields.io/twitter/follow/GitHubVS.svg?style=social "Follow GitHubVS")](https://twitter.com/githubvs?ref_src=twsrc%5Etfw) [![Join the chat at https://gitter.im/github/VisualStudio](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/github/VisualStudio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2626

2727
## Documentation
2828
Visit the [documentation](https://github.com/github/VisualStudio/tree/master/docs) for details on how to use the features in the GitHub Extension for Visual Studio.
@@ -39,6 +39,7 @@ Beta releases will have `(beta)` in their title in the gallery, following the ve
3939

4040
* Visual Studio 2017 (15.7.4)+
4141
* Visual Studio SDK
42+
* The built VSIX will work with Visual Studio 2015 or newer
4243

4344
## Build
4445

src/GitHub.App/Services/RepositoryCloneService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public async Task<ViewerRepositoriesModel> ReadViewerRepositories(HostAddress ad
114114
/// <inheritdoc/>
115115
public async Task CloneOrOpenRepository(
116116
CloneDialogResult cloneDialogResult,
117-
object progress = null)
117+
object progress = null,
118+
CancellationToken? cancellationToken = null)
118119
{
119120
Guard.ArgumentNotNull(cloneDialogResult, nameof(cloneDialogResult));
120121

@@ -147,7 +148,7 @@ public async Task CloneOrOpenRepository(
147148
else
148149
{
149150
var cloneUrl = repositoryUrl.ToString();
150-
await CloneRepository(cloneUrl, repositoryPath, progress).ConfigureAwait(true);
151+
await CloneRepository(cloneUrl, repositoryPath, progress, cancellationToken).ConfigureAwait(true);
151152

152153
if (isDotCom)
153154
{
@@ -197,7 +198,8 @@ bool IsSolutionInRepository(string repositoryPath)
197198
public async Task CloneRepository(
198199
string cloneUrl,
199200
string repositoryPath,
200-
object progress = null)
201+
object progress = null,
202+
CancellationToken? cancellationToken = null)
201203
{
202204
Guard.ArgumentNotEmptyString(cloneUrl, nameof(cloneUrl));
203205
Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath));
@@ -210,7 +212,7 @@ public async Task CloneRepository(
210212

211213
try
212214
{
213-
await vsGitServices.Clone(cloneUrl, repositoryPath, true, progress);
215+
await vsGitServices.Clone(cloneUrl, repositoryPath, true, progress, cancellationToken);
214216
await usageTracker.IncrementCounter(x => x.NumberOfClones);
215217

216218
if (repositoryPath.StartsWith(DefaultClonePath, StringComparison.OrdinalIgnoreCase))

src/GitHub.Exports.Reactive/Services/IRepositoryCloneService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Threading;
32
using System.Threading.Tasks;
43
using GitHub.Models;
54
using GitHub.Primitives;
@@ -27,11 +26,13 @@ public interface IRepositoryCloneService
2726
/// System.IProgress&lt;Microsoft.VisualStudio.Shell.ServiceProgressData&gt;, but
2827
/// as that type is only available in VS2017+ it is typed as <see cref="object"/> here.
2928
/// </param>
29+
/// <param name="cancellationToken">A cancellation token.</param>
3030
/// <returns></returns>
3131
Task CloneRepository(
3232
string cloneUrl,
3333
string repositoryPath,
34-
object progress = null);
34+
object progress = null,
35+
CancellationToken? cancellationToken = null);
3536

3637
/// <summary>
3738
/// Clones the specified repository into the specified directory or opens it if the directory already exists.
@@ -45,7 +46,8 @@ Task CloneRepository(
4546
/// <returns></returns>
4647
Task CloneOrOpenRepository(
4748
CloneDialogResult cloneDialogResult,
48-
object progress = null);
49+
object progress = null,
50+
CancellationToken? cancellationToken = null);
4951

5052
/// <summary>
5153
/// Checks whether the specified destination directory already exists.

src/GitHub.Exports/Services/IVSGitServices.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Threading;
34
using System.Threading.Tasks;
45
using GitHub.Models;
56

@@ -20,13 +21,15 @@ public interface IVSGitServices
2021
/// System.IProgress&lt;Microsoft.VisualStudio.Shell.ServiceProgressData&gt;, but
2122
/// as that type is only available in VS2017+ it is typed as <see cref="object"/> here.
2223
/// </param>
24+
/// <param name="cancellationToken">A cancellation token.</param>
2325
/// <seealso cref="System.IProgress{T}"/>
2426
/// <seealso cref="Microsoft.VisualStudio.Shell.ServiceProgressData"/>
2527
Task Clone(
2628
string cloneUrl,
2729
string clonePath,
2830
bool recurseSubmodules,
29-
object progress = null);
31+
object progress = null,
32+
CancellationToken? cancellationToken = null);
3033

3134
string GetActiveRepoPath();
3235
LibGit2Sharp.IRepository GetActiveRepo();

src/GitHub.StartPage/StartPagePackage.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async Task<CodeContainer> RunAcquisition(IProgress<ServiceProgressData> download
5757
try
5858
{
5959
var uiProvider = await Task.Run(() => Package.GetGlobalService(typeof(IGitHubServiceProvider)) as IGitHubServiceProvider);
60-
request = await ShowCloneDialog(uiProvider, downloadProgress, repository);
60+
request = await ShowCloneDialog(uiProvider, downloadProgress, cancellationToken, repository);
6161
}
6262
catch (Exception e)
6363
{
@@ -81,9 +81,10 @@ async Task<CodeContainer> RunAcquisition(IProgress<ServiceProgressData> download
8181
lastAccessed: DateTimeOffset.UtcNow);
8282
}
8383

84-
async Task<CloneDialogResult> ShowCloneDialog(
84+
static async Task<CloneDialogResult> ShowCloneDialog(
8585
IGitHubServiceProvider gitHubServiceProvider,
8686
IProgress<ServiceProgressData> progress,
87+
CancellationToken cancellationToken,
8788
RepositoryModel repository = null)
8889
{
8990
var dialogService = gitHubServiceProvider.GetService<IDialogService>();
@@ -110,7 +111,7 @@ async Task<CloneDialogResult> ShowCloneDialog(
110111
{
111112
try
112113
{
113-
await cloneService.CloneOrOpenRepository(result, progress);
114+
await cloneService.CloneOrOpenRepository(result, progress, cancellationToken);
114115
usageTracker.IncrementCounter(x => x.NumberOfStartPageClones).Forget();
115116
}
116117
catch

src/GitHub.TeamFoundation.14/Services/VSGitServices.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading;
23
using System.Collections.Generic;
34
using System.Diagnostics.CodeAnalysis;
45
using System.ComponentModel.Composition;
@@ -74,7 +75,8 @@ public async Task Clone(
7475
string cloneUrl,
7576
string clonePath,
7677
bool recurseSubmodules,
77-
object progress = null)
78+
object progress = null,
79+
CancellationToken? cancellationToken = null)
7880
{
7981
var teamExplorer = serviceProvider.TryGetService<ITeamExplorer>();
8082
Assumes.Present(teamExplorer);
@@ -84,13 +86,13 @@ public async Task Clone(
8486
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
8587
await WaitForCloneOnHomePageAsync(teamExplorer);
8688
#elif TEAMEXPLORER15 || TEAMEXPLORER16
87-
// The ServiceProgressData type is in a Visual Studio 2019 assembly that we don't currently have access to.
88-
// Using reflection to call the CloneAsync in order to avoid conflicts with the Visual Studio 2017 version.
89-
// Progress won't be displayed on the status bar, but it appears prominently on the Team Explorer Home view.
89+
// The progress parameter uses the ServiceProgressData type which is defined in
90+
// Microsoft.VisualStudio.Shell.Framework. Referencing this assembly directly
91+
// would cause type conflicts, so we're using reflection to call CloneAsync.
9092
var gitExt = serviceProvider.GetService<IGitActionsExt>();
9193
var cloneAsyncMethod = typeof(IGitActionsExt).GetMethod(nameof(IGitActionsExt.CloneAsync));
9294
Assumes.NotNull(cloneAsyncMethod);
93-
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, null, null };
95+
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, cancellationToken, progress };
9496
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitExt, cloneParameters);
9597

9698
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home

test/GitHub.VisualStudio.UnitTests/GitHub.VisualStudio.UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<ItemGroup>
2222
<PackageReference Include="Codecov" Version="1.1.0" />
2323
<PackageReference Include="Madskristensen.VisualStudio.SDK" Version="14.3.75-pre" />
24+
<PackageReference Include="NCrunch.Framework" Version="3.17.0" />
2425
<PackageReference Include="NSubstitute" Version="2.0.3" />
2526
<PackageReference Include="NUnit" version="3.9.0" />
2627
<PackageReference Include="OpenCover" Version="4.6.519" />

test/GitHub.VisualStudio.UnitTests/GitHubAssemblyTests.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
using System.IO;
1+
using System;
2+
using System.IO;
3+
using System.Linq;
24
using System.Reflection;
5+
using NCrunch.Framework;
36
using NUnit.Framework;
47

58
public class GitHubAssemblyTests
@@ -15,8 +18,34 @@ public void GitHub_Assembly_Should_Not_Reference_DesignTime_Assembly(string asse
1518
}
1619
}
1720

21+
[Theory]
22+
public void GitHub_Assembly_Should_Not_Reference_System_Net_Http_Above_4_0(string assemblyFile)
23+
{
24+
var asm = Assembly.LoadFrom(assemblyFile);
25+
foreach (var referencedAssembly in asm.GetReferencedAssemblies())
26+
{
27+
if (referencedAssembly.Name == "System.Net.Http")
28+
{
29+
Assert.That(referencedAssembly.Version, Is.EqualTo(new Version("4.0.0.0")));
30+
}
31+
}
32+
}
33+
1834
[DatapointSource]
19-
string[] GitHubAssemblies => Directory.GetFiles(AssemblyDirectory, "GitHub.*.dll");
35+
string[] GetGitHubAssemblies()
36+
{
37+
var prefix = "GitHub.";
38+
if (NCrunchEnvironment.NCrunchIsResident())
39+
{
40+
return NCrunchEnvironment.GetAllAssemblyLocations()
41+
.Where(p => Path.GetFileName(p).StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
42+
.ToArray();
43+
}
44+
else
45+
{
46+
var dir = Path.GetDirectoryName(GetType().Assembly.Location);
47+
return Directory.GetFiles(dir, $"{prefix}*.dll");
48+
}
49+
}
2050

21-
string AssemblyDirectory => Path.GetDirectoryName(GetType().Assembly.Location);
2251
}

0 commit comments

Comments
 (0)