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

Commit 9a9bb65

Browse files
author
Meaghan Lewis
authored
Merge branch 'master' into update-authenticating-to-github
2 parents dc7bfd3 + e948cca commit 9a9bb65

File tree

70 files changed

+2193
-863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2193
-863
lines changed

ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Hello! Please read the contributing guidelines before submitting an issue regarding the GitHub Extension for Visual Studio.
22

3-
- GitHub Extension for Visual Studio version:
3+
- GitHub Extension for Visual Studio version:
44
- Visual Studio version:
55

66
__What happened__ (with steps, logs and screenshots, if possible)

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2.4.2.{build}'
1+
version: '2.4.3.{build}'
22
skip_tags: true
33
install:
44
- ps: |

src/GitHub.Api/SimpleApiClient.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async Task<Repository> GetRepositoryInternal()
7272
if (repo != null)
7373
{
7474
hasWiki = await HasWikiInternal(repo);
75-
isEnterprise = await IsEnterpriseInternal();
75+
isEnterprise = isEnterprise ?? await IsEnterpriseInternal();
7676
repositoryCache = repo;
7777
}
7878
owner = ownerLogin;
@@ -99,9 +99,14 @@ public bool HasWiki()
9999
return hasWiki.HasValue && hasWiki.Value;
100100
}
101101

102-
public bool IsEnterprise()
102+
public async Task<bool> IsEnterprise()
103103
{
104-
return isEnterprise.HasValue && isEnterprise.Value;
104+
if (!isEnterprise.HasValue)
105+
{
106+
isEnterprise = await IsEnterpriseInternal();
107+
}
108+
109+
return isEnterprise ?? false;
105110
}
106111

107112
async Task<bool> HasWikiInternal(Repository repo)

src/GitHub.App/Api/ApiClient.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static string GetMachineNameSafe()
157157
}
158158
catch (Exception e)
159159
{
160-
log.Information(e, "Failed to retrieve host name using `DNS.GetHostName`");
160+
log.Warning(e, "Failed to retrieve host name using `DNS.GetHostName`");
161161
try
162162
{
163163
return Environment.MachineName;
@@ -242,7 +242,8 @@ public IObservable<PullRequest> GetPullRequestsForRepository(string owner, strin
242242
Guard.ArgumentNotEmptyString(name, nameof(name));
243243

244244
return gitHubClient.PullRequest.GetAllForRepository(owner, name,
245-
new PullRequestRequest {
245+
new PullRequestRequest
246+
{
246247
State = ItemStateFilter.All,
247248
SortProperty = PullRequestSort.Updated,
248249
SortDirection = SortDirection.Descending
@@ -268,7 +269,7 @@ public IObservable<Branch> GetBranches(string owner, string repo)
268269
Guard.ArgumentNotEmptyString(owner, nameof(owner));
269270
Guard.ArgumentNotEmptyString(repo, nameof(repo));
270271

271-
#pragma warning disable CS0618
272+
#pragma warning disable 618
272273
// GetAllBranches is obsolete, but don't want to introduce the change to fix the
273274
// warning in the PR, so disabling for now.
274275
return gitHubClient.Repository.GetAllBranches(owner, repo);

src/GitHub.App/GitHub.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
<Compile Include="Models\PullRequestDetailArgument.cs" />
155155
<Compile Include="Services\EnterpriseCapabilitiesService.cs" />
156156
<Compile Include="Services\GlobalConnection.cs" />
157+
<Compile Include="Services\PullRequestEditorService.cs" />
157158
<Compile Include="Services\TeamExplorerContext.cs" />
158159
<Compile Include="Services\OAuthCallbackListener.cs" />
159160
<Compile Include="ViewModels\Dialog\GistCreationViewModel.cs" />

src/GitHub.App/Resources.Designer.cs

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.App/Resources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,13 @@
285285
<data name="WorkingDirectoryHasUncommittedCHanges" xml:space="preserve">
286286
<value>Cannot checkout as your working directory has uncommitted changes.</value>
287287
</data>
288+
<data name="SyncSubmodules" xml:space="preserve">
289+
<value>Sync {0} submodules</value>
290+
</data>
291+
<data name="CouldntFindGitOnPath" xml:space="preserve">
292+
<value>Couldn't find Git.exe on PATH.
293+
294+
Please install Git for Windows from:
295+
https://git-scm.com/download/win</value>
296+
</data>
288297
</root>

src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public PullRequestDetailViewModelDesigner()
9494
public ReactiveCommand<Unit> Checkout { get; }
9595
public ReactiveCommand<Unit> Pull { get; }
9696
public ReactiveCommand<Unit> Push { get; }
97+
public ReactiveCommand<Unit> SyncSubmodules { get; }
9798
public ReactiveCommand<object> OpenOnGitHub { get; }
9899
public ReactiveCommand<object> DiffFile { get; }
99100
public ReactiveCommand<object> DiffFileWithWorkingDirectory { get; }

src/GitHub.Exports.Reactive/Services/PullRequestEditorService.cs renamed to src/GitHub.App/Services/PullRequestEditorService.cs

File renamed without changes.

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel.Composition;
33
using System.IO;
44
using System.Linq;
5+
using System.Diagnostics;
56
using GitHub.Models;
67
using System.Reactive.Linq;
78
using Rothko;
@@ -103,13 +104,44 @@ public IObservable<IReadOnlyList<CommitMessage>> GetMessagesForUniqueCommits(
103104
});
104105
}
105106

107+
public IObservable<int> CountSubmodulesToSync(ILocalRepositoryModel repository)
108+
{
109+
using (var repo = gitService.GetRepository(repository.LocalPath))
110+
{
111+
var count = 0;
112+
foreach (var submodule in repo.Submodules)
113+
{
114+
var status = submodule.RetrieveStatus();
115+
if ((status & SubmoduleStatus.WorkDirAdded) != 0)
116+
{
117+
count++;
118+
}
119+
else if ((status & SubmoduleStatus.WorkDirDeleted) != 0)
120+
{
121+
count++;
122+
}
123+
else if ((status & SubmoduleStatus.WorkDirModified) != 0)
124+
{
125+
count++;
126+
}
127+
else if ((status & SubmoduleStatus.WorkDirUninitialized) != 0)
128+
{
129+
count++;
130+
}
131+
}
132+
133+
return Observable.Return(count);
134+
}
135+
}
136+
106137
public IObservable<bool> IsWorkingDirectoryClean(ILocalRepositoryModel repository)
107138
{
108139
// The `using` appears to resolve this issue:
109140
// https://github.com/github/VisualStudio/issues/1306
110141
using (var repo = gitService.GetRepository(repository.LocalPath))
111142
{
112-
var isClean = !IsFilthy(repo.RetrieveStatus());
143+
var statusOptions = new StatusOptions { ExcludeSubmodules = true };
144+
var isClean = !IsFilthy(repo.RetrieveStatus(statusOptions));
113145
return Observable.Return(isClean);
114146
}
115147
}
@@ -154,6 +186,69 @@ public IObservable<Unit> Push(ILocalRepositoryModel repository)
154186
});
155187
}
156188

189+
public async Task<bool> SyncSubmodules(ILocalRepositoryModel repository, Action<string> progress)
190+
{
191+
var exitCode = await Where("git");
192+
if (exitCode != 0)
193+
{
194+
progress(App.Resources.CouldntFindGitOnPath);
195+
return false;
196+
}
197+
198+
return await SyncSubmodules(repository.LocalPath, progress) == 0;
199+
}
200+
201+
// LibGit2Sharp has limited submodule support so shelling out Git.exe for submodule commands.
202+
async Task<int> SyncSubmodules(string workingDir, Action<string> progress)
203+
{
204+
var cmdArguments = "/C git submodule init & git submodule sync --recursive & git submodule update --recursive";
205+
var startInfo = new ProcessStartInfo("cmd", cmdArguments)
206+
{
207+
WorkingDirectory = workingDir,
208+
UseShellExecute = false,
209+
CreateNoWindow = true,
210+
RedirectStandardOutput = true,
211+
RedirectStandardError = true
212+
};
213+
214+
using (var process = Process.Start(startInfo))
215+
{
216+
await Task.WhenAll(
217+
ReadLinesAsync(process.StandardOutput, progress),
218+
ReadLinesAsync(process.StandardError, progress),
219+
Task.Run(() => process.WaitForExit()));
220+
return process.ExitCode;
221+
}
222+
}
223+
224+
static Task<int> Where(string fileName)
225+
{
226+
return Task.Run(() =>
227+
{
228+
var cmdArguments = "/C WHERE /Q " + fileName;
229+
var startInfo = new ProcessStartInfo("cmd", cmdArguments)
230+
{
231+
UseShellExecute = false,
232+
CreateNoWindow = true
233+
};
234+
235+
using (var process = Process.Start(startInfo))
236+
{
237+
process.WaitForExit();
238+
return process.ExitCode;
239+
}
240+
});
241+
}
242+
243+
static async Task ReadLinesAsync(TextReader reader, Action<string> progress)
244+
{
245+
string line;
246+
while ((line = await reader.ReadLineAsync()) != null)
247+
{
248+
progress(line);
249+
}
250+
}
251+
157252
public IObservable<Unit> Checkout(ILocalRepositoryModel repository, IPullRequestModel pullRequest, string localBranchName)
158253
{
159254
return Observable.Defer(async () =>

0 commit comments

Comments
 (0)