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

Commit ba9773f

Browse files
Merge branch 'master' into autocompletebox
2 parents 653cc79 + e98aa41 commit ba9773f

40 files changed

+296
-190
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>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you have an existing clone, make sure to run `git submodule sync` to update y
1212

1313
## About
1414

15-
The GitHub Extension for Visual Studio provides GitHub integration in Visual Studio 2015.
15+
The GitHub Extension for Visual Studio provides GitHub integration in Visual Studio 2015 and newer.
1616
Most of the extension UI lives in the Team Explorer pane, which is available from the View menu.
1717

1818
Official builds of this extension are available at [the official website](https://visualstudio.github.com).

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/GitHub.App.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@
4646
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="1.0.164" />
4747
<PackageReference Include="Madskristensen.VisualStudio.SDK" Version="14.3.75-pre" />
4848
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.6.1" />
49+
<PackageReference Include="Microsoft.VisualStudio.StaticReviews.Embeddable" Version="0.1.14-alpha" />
4950
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
5051
<PackageReference Include="Rothko" Version="0.0.3-ghfvs" />
5152
<PackageReference Include="Serilog" Version="2.5.0" />
5253
<PackageReference Include="SerilogAnalyzer" Version="0.12.0.0" />
5354
<PackageReference Include="Stateless" Version="2.5.56.0" targetFramework="net45" />
5455
</ItemGroup>
55-
</Project>
56+
<Target Name="LinkStaticReviewsEmbeddableAssemblies" AfterTargets="ResolveReferences" BeforeTargets="FindReferenceAssembliesForReferences">
57+
<ItemGroup>
58+
<ReferencePath Condition="'%(FileName)' == 'Microsoft.VisualStudio.StaticReviews.Embeddable'">
59+
<EmbedInteropTypes>true</EmbedInteropTypes>
60+
</ReferencePath>
61+
</ItemGroup>
62+
</Target>
63+
</Project>

src/GitHub.App/SampleData/SampleViewModels.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public RepositoryCreationViewModelDesigner()
2929
RepositoryName = "Hello-World";
3030
Description = "A description";
3131
KeepPrivate = true;
32-
CanKeepPrivate = true;
3332
Accounts = new ReactiveList<IAccount>
3433
{
3534
new AccountDesigner { Login = "shana" },
@@ -80,12 +79,6 @@ public ReactiveCommand<Unit, Unit> BrowseForDirectory
8079
private set;
8180
}
8281

83-
public bool CanKeepPrivate
84-
{
85-
get;
86-
private set;
87-
}
88-
8982
public ReactiveCommand<Unit, Unit> CreateRepository
9083
{
9184
get;
@@ -146,24 +139,6 @@ public IAccount SelectedAccount
146139
set;
147140
}
148141

149-
public bool ShowUpgradePlanWarning
150-
{
151-
get;
152-
private set;
153-
}
154-
155-
public bool ShowUpgradeToMicroPlanWarning
156-
{
157-
get;
158-
private set;
159-
}
160-
161-
public ICommand UpgradeAccountPlan
162-
{
163-
get;
164-
private set;
165-
}
166-
167142
public IReadOnlyList<GitIgnoreItem> GitIgnoreTemplates
168143
{
169144
get; private set;

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.App/Services/PullRequestService.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
using System.Reactive;
99
using System.Reactive.Linq;
1010
using System.Reactive.Threading.Tasks;
11+
using System.Runtime.InteropServices;
1112
using System.Text;
1213
using System.Text.RegularExpressions;
14+
using System.Threading;
1315
using System.Threading.Tasks;
1416
using System.Windows.Forms;
1517
using GitHub.Api;
@@ -19,6 +21,7 @@
1921
using GitHub.Models;
2022
using GitHub.Primitives;
2123
using LibGit2Sharp;
24+
using Microsoft.VisualStudio.StaticReviews.Contracts;
2225
using Octokit.GraphQL;
2326
using Octokit.GraphQL.Model;
2427
using Rothko;
@@ -32,7 +35,7 @@ namespace GitHub.Services
3235
{
3336
[Export(typeof(IPullRequestService))]
3437
[PartCreationPolicy(CreationPolicy.Shared)]
35-
public class PullRequestService : IPullRequestService
38+
public class PullRequestService : IPullRequestService, IStaticReviewFileMap
3639
{
3740
const string SettingCreatedByGHfVS = "created-by-ghfvs";
3841
const string SettingGHfVSPullRequest = "ghfvs-pr-owner-number";
@@ -58,6 +61,8 @@ public class PullRequestService : IPullRequestService
5861
readonly IOperatingSystem os;
5962
readonly IUsageTracker usageTracker;
6063

64+
readonly IDictionary<string, (string commitId, string repoPath)> tempFileMappings;
65+
6166
[ImportingConstructor]
6267
public PullRequestService(
6368
IGitClient gitClient,
@@ -73,6 +78,7 @@ public PullRequestService(
7378
this.graphqlFactory = graphqlFactory;
7479
this.os = os;
7580
this.usageTracker = usageTracker;
81+
this.tempFileMappings = new Dictionary<string, (string commitId, string repoPath)>(StringComparer.OrdinalIgnoreCase);
7682
}
7783

7884
public async Task<Page<PullRequestListItemModel>> ReadPullRequests(
@@ -755,6 +761,12 @@ public async Task<string> ExtractToTempFile(
755761
}
756762
}
757763

764+
lock (this.tempFileMappings)
765+
{
766+
string gitRelativePath = relativePath.TrimStart('/').Replace('\\', '/');
767+
this.tempFileMappings[CanonicalizeLocalFilePath(tempFilePath)] = (commitSha, gitRelativePath);
768+
}
769+
758770
return tempFilePath;
759771
}
760772

@@ -827,6 +839,28 @@ public bool ConfirmCancelPendingReview()
827839
MessageBoxIcon.Question) == DialogResult.Yes;
828840
}
829841

842+
/// <inheritdoc />
843+
public Task<string> GetObjectishFromLocalPathAsync(string localPath, CancellationToken cancellationToken)
844+
{
845+
lock (this.tempFileMappings)
846+
{
847+
var canonicalizedPath = CanonicalizeLocalFilePath(localPath);
848+
if (this.tempFileMappings.TryGetValue(canonicalizedPath, out (string commitId, string repoPath) result))
849+
{
850+
return Task.FromResult($"{result.commitId}:{result.repoPath}");
851+
}
852+
}
853+
854+
return Task.FromResult<string>(null);
855+
}
856+
857+
/// <inheritdoc />
858+
public Task<string> GetLocalPathFromObjectishAsync(string objectish, CancellationToken cancellationToken)
859+
{
860+
throw new NotImplementedException();
861+
}
862+
863+
830864
async Task<string> CreateRemote(IRepository repo, UriString cloneUri)
831865
{
832866
foreach (var remote in repo.Network.Remotes)
@@ -1006,6 +1040,12 @@ static string BuildGHfVSConfigKeyValue(string owner, int number)
10061040
return default;
10071041
}
10081042

1043+
static string CanonicalizeLocalFilePath(string localPath)
1044+
{
1045+
localPath = localPath.Replace("\\\\", "\\");
1046+
return Path.GetFullPath(localPath);
1047+
}
1048+
10091049
class ListItemAdapter : PullRequestListItemModel
10101050
{
10111051
public IList<ReviewAdapter> Reviews { get; set; }

src/GitHub.App/Services/RepositoryCloneService.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Linq;
66
using System.Reactive.Linq;
7+
using System.Threading;
78
using System.Threading.Tasks;
89
using GitHub.Api;
910
using GitHub.Extensions;
@@ -69,13 +70,8 @@ public async Task<ViewerRepositoriesModel> ReadViewerRepositories(HostAddress ad
6970
{
7071
var order = new RepositoryOrder
7172
{
72-
Field = RepositoryOrderField.Name,
73-
Direction = OrderDirection.Asc
74-
};
75-
76-
var affiliation = new RepositoryAffiliation?[]
77-
{
78-
RepositoryAffiliation.Owner, RepositoryAffiliation.Collaborator
73+
Field = RepositoryOrderField.PushedAt,
74+
Direction = OrderDirection.Desc
7975
};
8076

8177
var repositorySelection = new Fragment<Repository, RepositoryListItemModel>(
@@ -94,14 +90,17 @@ public async Task<ViewerRepositoriesModel> ReadViewerRepositories(HostAddress ad
9490
.Select(viewer => new ViewerRepositoriesModel
9591
{
9692
Owner = viewer.Login,
97-
Repositories = viewer.Repositories(null, null, null, null, null, null, null, order, affiliation, null)
93+
Repositories = viewer.Repositories(null, null, null, null, null, null, null, order, null, null)
9894
.AllPages()
9995
.Select(repositorySelection).ToList(),
96+
ContributedToRepositories = viewer.RepositoriesContributedTo(100, null, null, null, null, null, null, order, null)
97+
.Nodes
98+
.Select(repositorySelection).ToList(),
10099
Organizations = viewer.Organizations(null, null, null, null).AllPages().Select(org => new
101100
{
102101
org.Login,
103-
Repositories = org.Repositories(null, null, null, null, null, null, null, order, null, null)
104-
.AllPages()
102+
Repositories = org.Repositories(100, null, null, null, null, null, null, order, null, null)
103+
.Nodes
105104
.Select(repositorySelection).ToList()
106105
}).ToDictionary(x => x.Login, x => (IReadOnlyList<RepositoryListItemModel>)x.Repositories),
107106
}).Compile();

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ public async Task InitializeAsync(IConnection connection)
137137

138138
this.WhenAnyValue(x => x.SelectedTabIndex).Subscribe(x => tabs[x].Activate().Forget());
139139

140-
// When a clipboard URL has been set or a user is in group A, show the URL tab by default
141-
if (!string.IsNullOrEmpty(UrlTab.Url) || await IsGroupA().ConfigureAwait(false))
140+
// When a clipboard URL has been set, show the URL tab by default
141+
if (!string.IsNullOrEmpty(UrlTab.Url))
142142
{
143143
SelectedTabIndex = 2;
144144
}
@@ -157,14 +157,6 @@ public async Task InitializeAsync(IConnection connection)
157157
}
158158
}
159159

160-
// Put 50% of users in group A
161-
async Task<bool> IsGroupA()
162-
{
163-
var userGuid = await usageService.GetUserGuid().ConfigureAwait(false);
164-
var lastByte = userGuid.ToByteArray().Last();
165-
return lastByte % 2 == 0;
166-
}
167-
168160
void BrowseForDirectory()
169161
{
170162
var result = os.Dialog.BrowseForDirectory(Path, Resources.BrowseForDirectory);

0 commit comments

Comments
 (0)