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

Commit 5e2b1b0

Browse files
Merge branch 'master' into pull-request-status-circle
2 parents d8f9e87 + 337f266 commit 5e2b1b0

File tree

9 files changed

+55
-17
lines changed

9 files changed

+55
-17
lines changed

Directory.Build.Props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<Product>GitHub Extension for Visual Studio</Product>
4-
<Version>2.7.0.0</Version>
4+
<Version>2.8.0.0</Version>
55
<Copyright>Copyright © GitHub, Inc. 2014-2018</Copyright>
66
<LangVersion>7.3</LangVersion>
77
</PropertyGroup>

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: Visual Studio 2017
2-
version: '2.7.0.{build}'
2+
version: '2.8.0.{build}'
33
skip_tags: true
44
install:
55
- ps: |

src/GitHub.App/Services/DialogService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel.Composition;
33
using System.Threading.Tasks;
44
using GitHub.Api;
5+
using GitHub.Exports;
56
using GitHub.Extensions;
67
using GitHub.Factories;
78
using GitHub.Models;
@@ -38,7 +39,13 @@ public async Task<CloneDialogResult> ShowCloneDialog(IConnection connection, str
3839
if (string.IsNullOrEmpty(url))
3940
{
4041
var clipboardContext = gitHubContextService.FindContextFromClipboard();
41-
url = clipboardContext?.Url;
42+
switch (clipboardContext?.LinkType)
43+
{
44+
case LinkType.Blob:
45+
case LinkType.Repository:
46+
url = clipboardContext?.Url;
47+
break;
48+
}
4249
}
4350

4451
var viewModel = factory.CreateViewModel<IRepositoryCloneViewModel>();

src/GitHub.App/Services/GitHubContextService.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,27 @@ public GitHubContext FindContextFromUrl(string url)
124124
Url = uri
125125
};
126126

127-
var repositoryPrefix = uri.ToRepositoryUrl().ToString() + "/";
127+
if (uri.Owner == null)
128+
{
129+
context.LinkType = LinkType.Unknown;
130+
return context;
131+
}
132+
133+
if (uri.RepositoryName == null)
134+
{
135+
context.LinkType = LinkType.Unknown;
136+
return context;
137+
}
138+
139+
var repositoryUrl = uri.ToRepositoryUrl().ToString();
140+
if (string.Equals(url, repositoryUrl, StringComparison.OrdinalIgnoreCase) ||
141+
string.Equals(url, repositoryUrl + ".git", StringComparison.OrdinalIgnoreCase))
142+
{
143+
context.LinkType = LinkType.Repository;
144+
return context;
145+
}
146+
147+
var repositoryPrefix = repositoryUrl + "/";
128148
if (!url.StartsWith(repositoryPrefix, StringComparison.OrdinalIgnoreCase))
129149
{
130150
return context;

src/GitHub.Exports/Exports/ExportMetadata.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public enum LinkType
2121
{
2222
Unknown,
2323
Blob,
24-
Blame
24+
Blame,
25+
Repository
2526
}
2627

2728
/// <summary>

src/GitHub.VisualStudio/UI/GitHubPane.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ protected override void Initialize()
8282
// Using JoinableTaskFactory from parent AsyncPackage. That way if VS shuts down before this
8383
// work is done, we won't risk crashing due to arbitrary work going on in background threads.
8484
var asyncPackage = (AsyncPackage)Package;
85-
viewModelTask = asyncPackage.JoinableTaskFactory.RunAsync(() => InitializeAsync(asyncPackage));
85+
JoinableTaskFactory = asyncPackage.JoinableTaskFactory;
86+
87+
viewModelTask = JoinableTaskFactory.RunAsync(() => InitializeAsync(asyncPackage));
8688
}
8789

8890
public Task<IGitHubPaneViewModel> GetViewModelAsync() => viewModelTask.JoinAsync();
@@ -123,7 +125,7 @@ public override IVsSearchTask CreateSearch(uint dwCookie, IVsSearchQuery pSearch
123125

124126
if (pane != null)
125127
{
126-
return new SearchTask(pane, dwCookie, pSearchQuery, pSearchCallback);
128+
return new SearchTask(JoinableTaskFactory, pane, dwCookie, pSearchQuery, pSearchCallback);
127129
}
128130

129131
return null;
@@ -175,37 +177,38 @@ void UpdateSearchHost(bool enabled, string query)
175177
{
176178
SearchHost.IsEnabled = enabled;
177179

178-
var searchString = SearchHost.SearchQuery?.SearchString;
179-
if (searchString?.Trim() != query?.Trim())
180+
if (SearchHost.SearchQuery?.SearchString != query)
180181
{
181-
// SearchAsync will crash the process if we send it a duplicate string.
182-
// There is a SearchTrimsWhitespace setting that makes searched with leading or trailing
183-
// white-space appear as duplicates. We compare the query with trimmed white-space to avoid this.
184-
// https://github.com/github/VisualStudio/issues/1948
185182
SearchHost.SearchAsync(query != null ? new SearchQuery(query) : null);
186183
}
187184
}
188185
}
189186

190187
class SearchTask : VsSearchTask
191188
{
189+
readonly JoinableTaskFactory joinableTaskFactory;
192190
readonly IGitHubPaneViewModel viewModel;
193191

194192
public SearchTask(
193+
JoinableTaskFactory joinableTaskFactory,
195194
IGitHubPaneViewModel viewModel,
196195
uint dwCookie,
197196
IVsSearchQuery pSearchQuery,
198197
IVsSearchCallback pSearchCallback)
199198
: base(dwCookie, pSearchQuery, pSearchCallback)
200199
{
200+
this.joinableTaskFactory = joinableTaskFactory;
201201
this.viewModel = viewModel;
202202
}
203203

204204
protected override void OnStartSearch()
205205
{
206-
ThreadHelper.ThrowIfNotOnUIThread();
206+
joinableTaskFactory.RunAsync(async () =>
207+
{
208+
await joinableTaskFactory.SwitchToMainThreadAsync();
209+
viewModel.SearchQuery = SearchQuery.SearchString;
210+
});
207211

208-
viewModel.SearchQuery = SearchQuery.SearchString;
209212
base.OnStartSearch();
210213
}
211214

@@ -224,5 +227,7 @@ public SearchQuery(string query)
224227

225228
public uint GetTokens(uint dwMaxTokens, IVsSearchToken[] rgpSearchTokens) => 0;
226229
}
230+
231+
public JoinableTaskFactory JoinableTaskFactory { get; private set; }
227232
}
228233
}

src/GitHub.VisualStudio/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.7.0.0" Language="en-US" Publisher="GitHub, Inc" />
4+
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.8.0.0" Language="en-US" Publisher="GitHub, Inc" />
55
<DisplayName>GitHub Extension for Visual Studio</DisplayName>
66
<Description xml:space="preserve">A Visual Studio Extension that brings the GitHub Flow into Visual Studio.</Description>
77
<PackageId>GitHub.VisualStudio</PackageId>

src/common/SolutionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
namespace System
1919
{
2020
internal static class AssemblyVersionInformation {
21-
internal const string Version = "2.7.0.0";
21+
internal const string Version = "2.8.0.0";
2222
}
2323
}

test/GitHub.App.UnitTests/Services/GitHubContextServiceTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ public void Url_EqualTo(string url, string expectUrl)
133133
Assert.That(context.Url?.ToString(), Is.EqualTo(expectUrl));
134134
}
135135

136+
[TestCase("https://github.com/github/VisualStudio", LinkType.Repository)]
137+
[TestCase("https://github.com/github/VisualStudio.git", LinkType.Repository)]
138+
[TestCase("https://github.com/github/VisualStudio/unknown/master/README.md", LinkType.Unknown)]
136139
[TestCase("https://github.com/github/VisualStudio/blob/master/README.md", LinkType.Blob)]
140+
[TestCase("https://github.com", LinkType.Unknown)]
141+
[TestCase("https://github.com/github", LinkType.Unknown)]
137142
[TestCase("https://github.com/github/VisualStudio/unknown/master/README.md", LinkType.Unknown)]
138143
public void LinkType_EqualTo(string url, LinkType expectLinkType)
139144
{

0 commit comments

Comments
 (0)