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

Commit 8101bac

Browse files
authored
Merge branch 'master' into devops/build-on-2019
2 parents f66f82d + 3e377a9 commit 8101bac

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,21 @@ bool FilterItem(object obj)
178178
{
179179
if (obj is IRepositoryItemViewModel item && !string.IsNullOrWhiteSpace(Filter))
180180
{
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);
181+
if (new UriString(Filter).IsHypertextTransferProtocol)
182+
{
183+
var urlString = item.Url.ToString();
184+
var urlStringWithGit = urlString + ".git";
185+
var urlStringWithSlash = urlString + "/";
186+
return
187+
urlString.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
188+
urlStringWithGit.Contains(Filter, StringComparison.OrdinalIgnoreCase) ||
189+
urlStringWithSlash.Contains(Filter, StringComparison.OrdinalIgnoreCase);
190+
}
191+
else
192+
{
193+
return
194+
item.Caption.Contains(Filter, StringComparison.CurrentCultureIgnoreCase);
195+
}
189196
}
190197

191198
return true;

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,22 @@ public async Task Clone(
8686
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
8787
await WaitForCloneOnHomePageAsync(teamExplorer);
8888
#elif TEAMEXPLORER15 || TEAMEXPLORER16
89+
// IGitActionsExt is proffered by SccProviderPackage, but isn't advertised.
90+
// To ensure that getting IGitActionsExt doesn't return null, we first request the
91+
// IGitExt service which is advertised. This forces SccProviderPackage to load
92+
// and proffer IGitActionsExt.
93+
var gitExt = serviceProvider.GetService(typeof(IGitExt));
94+
Assumes.NotNull(gitExt);
95+
var gitActionsExt = serviceProvider.GetService<IGitActionsExt>();
96+
Assumes.NotNull(gitActionsExt);
97+
8998
// The progress parameter uses the ServiceProgressData type which is defined in
9099
// Microsoft.VisualStudio.Shell.Framework. Referencing this assembly directly
91100
// would cause type conflicts, so we're using reflection to call CloneAsync.
92-
var gitExt = serviceProvider.GetService<IGitActionsExt>();
93101
var cloneAsyncMethod = typeof(IGitActionsExt).GetMethod(nameof(IGitActionsExt.CloneAsync));
94102
Assumes.NotNull(cloneAsyncMethod);
95103
var cloneParameters = new object[] { cloneUrl, clonePath, recurseSubmodules, cancellationToken, progress };
96-
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitExt, cloneParameters);
104+
var cloneTask = (Task)cloneAsyncMethod.Invoke(gitActionsExt, cloneParameters);
97105

98106
NavigateToHomePage(teamExplorer); // Show progress on Team Explorer - Home
99107
await cloneTask;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class TheFilterProperty
2626
[TestCase("https://github.com/jcansdale/TestDriven.Net", "owner", "name", "https://github.com/jcansdale/TestDriven.Net-issues", 1)]
2727
[TestCase("https://github.com/owner/name/", "owner", "name", "https://github.com/owner/name", 1, Description = "Trailing slash")]
2828
[TestCase("https://github.com/owner/name.git", "owner", "name", "https://github.com/owner/name", 1, Description = "Trailing .git")]
29+
[TestCase("github.com", "owner", "name", "https://github.com/owner/name", 0, Description = "Don't include host name in search")]
2930
public async Task Filter(string filter, string owner, string name, string url, int expectCount)
3031
{
3132
var contributedToRepositories = new[]

0 commit comments

Comments
 (0)