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

Commit

Permalink
Merge pull request #2122 from github/fix-checks-enterprise-nulls
Browse files Browse the repository at this point in the history
Fixing Checks GraphQL query on GitHub Enterprise
  • Loading branch information
StanleyGoldman authored Dec 12, 2018
2 parents 28fc322 + 2018d61 commit a4d7eb5
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.Props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<Product>GitHub Extension for Visual Studio</Product>
<Version>2.6.0.0</Version>
<Version>2.6.1.0</Version>
<Copyright>Copyright © GitHub, Inc. 2014-2018</Copyright>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
os: Visual Studio 2017
version: '2.6.0.{build}'
version: '2.6.1.{build}'
skip_tags: true
install:
- ps: |
Expand Down
14 changes: 8 additions & 6 deletions src/GitHub.App/Services/PullRequestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ public async Task<Page<PullRequestListItemModel>> ReadPullRequests(
LastCommit = pr.Commits(null, null, 1, null).Nodes.Select(commit =>
new LastCommitSummaryAdapter
{
Statuses = commit.Commit.Status
.Select(context =>
context.Contexts.Select(statusContext => new StatusSummaryModel
{
State = statusContext.State.FromGraphQl(),
}).ToList()
Statuses = commit.Commit.Status.Select(context =>
context == null
? null
: context.Contexts
.Select(statusContext => new StatusSummaryModel
{
State = statusContext.State.FromGraphQl()
}).ToList()
).SingleOrDefault()
}).ToList().FirstOrDefault(),
Author = new ActorModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullReq
bool refreshOnActivate;
Uri webUrl;
IDisposable sessionSubscription;
IReadOnlyList<IPullRequestCheckViewModel> checks;
IReadOnlyList<IPullRequestCheckViewModel> checks = Array.Empty<IPullRequestCheckViewModel>();

/// <summary>
/// Initializes a new instance of the <see cref="PullRequestDetailViewModel"/> class.
Expand Down Expand Up @@ -350,7 +350,7 @@ public async Task Load(PullRequestDetailModel pullRequest)
Body = !string.IsNullOrWhiteSpace(pullRequest.Body) ? pullRequest.Body : Resources.NoDescriptionProvidedMarkdown;
Reviews = PullRequestReviewSummaryViewModel.BuildByUser(Session.User, pullRequest).ToList();

Checks = PullRequestCheckViewModel.Build(viewViewModelFactory, pullRequest)?.ToList();
Checks = (IReadOnlyList<IPullRequestCheckViewModel>) PullRequestCheckViewModel.Build(viewViewModelFactory, pullRequest)?.ToList() ?? Array.Empty<IPullRequestCheckViewModel>();

await Files.InitializeAsync(Session);

Expand Down
38 changes: 24 additions & 14 deletions src/GitHub.InlineReviews/Services/PullRequestSessionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,19 @@ public virtual async Task<PullRequestDetailModel> ReadPullRequestDetail(HostAddr
var files = await apiClient.GetPullRequestFiles(owner, name, number).ToList();
var lastCommitModel = await GetPullRequestLastCommitAdapter(address, owner, name, number);

result.Statuses = lastCommitModel.Statuses;
result.CheckSuites = lastCommitModel.CheckSuites;
foreach (var checkSuite in result.CheckSuites)
result.Statuses = (IReadOnlyList<StatusModel>) lastCommitModel.Statuses ?? Array.Empty<StatusModel>();

if (lastCommitModel.CheckSuites == null)
{
checkSuite.HeadSha = lastCommitModel.HeadSha;
result.CheckSuites = Array.Empty<CheckSuiteModel>();
}
else
{
result.CheckSuites = lastCommitModel.CheckSuites;
foreach (var checkSuite in result.CheckSuites)
{
checkSuite.HeadSha = lastCommitModel.HeadSha;
}
}

result.ChangedFiles = files.Select(file => new PullRequestFileModel
Expand Down Expand Up @@ -829,16 +837,18 @@ async Task<LastCommitAdapter> GetPullRequestLastCommitAdapter(HostAddress addres
.PullRequest(Var(nameof(number))).Commits(last: 1).Nodes.Select(
commit => new LastCommitAdapter
{
Statuses = commit.Commit.Status
.Select(context =>
context.Contexts.Select(statusContext => new StatusModel
{
State = statusContext.State.FromGraphQl(),
Context = statusContext.Context,
TargetUrl = statusContext.TargetUrl,
Description = statusContext.Description,
}).ToList()
).SingleOrDefault()
Statuses = commit.Commit.Status == null ? null : commit.Commit.Status
.Select(context => context == null
? null
: context.Contexts
.Select(statusContext => new StatusModel
{
State = statusContext.State.FromGraphQl(),
Context = statusContext.Context,
TargetUrl = statusContext.TargetUrl,
Description = statusContext.Description,
}).ToList()
).SingleOrDefault()
}
).Compile();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
HeaderText="Checks"
IsExpanded="True"
Margin="0 8 0 0"
ghfvs:ScrollingVerticalStackPanel.IsFixed="true">
ghfvs:ScrollingVerticalStackPanel.IsFixed="true"
Visibility="{Binding Checks.Count, Converter={ghfvs:CountToVisibilityConverter}}">
<ItemsControl ItemsSource="{Binding Checks}" Margin="0 4 12 4">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.VisualStudio/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<Metadata>
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.6.0.0" Language="en-US" Publisher="GitHub, Inc" />
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.6.1.0" Language="en-US" Publisher="GitHub, Inc" />
<DisplayName>GitHub Extension for Visual Studio</DisplayName>
<Description xml:space="preserve">A Visual Studio Extension that brings the GitHub Flow into Visual Studio.</Description>
<PackageId>GitHub.VisualStudio</PackageId>
Expand Down Expand Up @@ -45,4 +45,4 @@
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0.25824.0,)" DisplayName="Visual Studio core editor" />
</Prerequisites>
</PackageManifest>
</PackageManifest>
2 changes: 1 addition & 1 deletion src/common/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
namespace System
{
internal static class AssemblyVersionInformation {
internal const string Version = "2.6.0.0";
internal const string Version = "2.6.1.0";
}
}

0 comments on commit a4d7eb5

Please sign in to comment.