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

Commit 94f98f0

Browse files
authored
Merge branch 'master' into fixes/pr-list-errors-2
2 parents 2a03f3f + 541e3ba commit 94f98f0

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@
405405
<HintPath>..\..\packages\Rx-PlatformServices.2.2.5-custom\lib\net45\System.Reactive.PlatformServices.dll</HintPath>
406406
<Private>True</Private>
407407
</Reference>
408+
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
409+
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
410+
</Reference>
408411
<Reference Include="System.Windows.Forms" />
409412
<Reference Include="System.Xaml" />
410413
<Reference Include="System.Xml" />

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -434,23 +434,12 @@ public async Task<PullRequestDetailModel> CreatePendingReview(
434434
{
435435
var address = HostAddress.Create(localRepository.CloneUrl.Host);
436436
var graphql = await graphqlFactory.CreateConnection(address);
437+
var (_, owner, number) = await CreatePendingReviewCore(localRepository, pullRequestId);
438+
var detail = await ReadPullRequestDetail(address, owner, localRepository.Name, number);
437439

438-
var review = new AddPullRequestReviewInput
439-
{
440-
PullRequestId = new ID(pullRequestId),
441-
};
442-
443-
var mutation = new Mutation()
444-
.AddPullRequestReview(review)
445-
.Select(x => new
446-
{
447-
x.PullRequestReview.Repository.Owner.Login,
448-
x.PullRequestReview.PullRequest.Number
449-
});
450-
451-
var result = await graphql.Run(mutation);
452440
await usageTracker.IncrementCounter(x => x.NumberOfPRReviewDiffViewInlineCommentStartReview);
453-
return await ReadPullRequestDetail(address, result.Login, localRepository.Name, result.Number);
441+
442+
return detail;
454443
}
455444

456445
/// <inheritdoc/>
@@ -652,9 +641,9 @@ public async Task<PullRequestDetailModel> PostStandaloneReviewCommentReply(
652641
string body,
653642
string inReplyTo)
654643
{
655-
var review = await CreatePendingReview(localRepository, pullRequestId);
656-
var comment = await PostPendingReviewCommentReply(localRepository, review.Id, body, inReplyTo);
657-
return await SubmitPendingReview(localRepository, review.Id, null, PullRequestReviewEvent.Comment);
644+
var (id, _, _) = await CreatePendingReviewCore(localRepository, pullRequestId);
645+
var comment = await PostPendingReviewCommentReply(localRepository, id, body, inReplyTo);
646+
return await SubmitPendingReview(localRepository, id, null, PullRequestReviewEvent.Comment);
658647
}
659648

660649
/// <inheritdoc/>
@@ -702,6 +691,29 @@ public async Task<PullRequestDetailModel> EditComment(ILocalRepositoryModel loca
702691
return await ReadPullRequestDetail(address, result.Login, localRepository.Name, result.Number);
703692
}
704693

694+
async Task<(string id, string owner, int number)> CreatePendingReviewCore(ILocalRepositoryModel localRepository, string pullRequestId)
695+
{
696+
var address = HostAddress.Create(localRepository.CloneUrl.Host);
697+
var graphql = await graphqlFactory.CreateConnection(address);
698+
699+
var input = new AddPullRequestReviewInput
700+
{
701+
PullRequestId = new ID(pullRequestId),
702+
};
703+
704+
var mutation = new Mutation()
705+
.AddPullRequestReview(input)
706+
.Select(x => new
707+
{
708+
Id = x.PullRequestReview.Id.Value,
709+
Owner = x.PullRequestReview.Repository.Owner.Login,
710+
x.PullRequestReview.PullRequest.Number
711+
});
712+
713+
var result = await graphql.Run(mutation);
714+
return (result.Id, result.Owner, result.Number);
715+
}
716+
705717
int GetUpdatedLineNumber(IInlineCommentThreadModel thread, IEnumerable<DiffChunk> diff)
706718
{
707719
var line = DiffUtilities.Match(diff, thread.DiffMatch);
@@ -724,7 +736,7 @@ Task<IRepository> GetRepository(ILocalRepositoryModel repository)
724736
static void BuildPullRequestThreads(PullRequestDetailModel model)
725737
{
726738
var commentsByReplyId = new Dictionary<string, List<CommentAdapter>>();
727-
739+
728740
// Get all comments that are not replies.
729741
foreach (CommentAdapter comment in model.Reviews.SelectMany(x => x.Comments))
730742
{
@@ -744,7 +756,6 @@ static void BuildPullRequestThreads(PullRequestDetailModel model)
744756
if (commentsByReplyId.TryGetValue(comment.ReplyTo, out thread))
745757
{
746758
thread.Add(comment);
747-
break;
748759
}
749760
}
750761
}

src/GitHub.InlineReviews/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<package id="Rx-PlatformServices" version="2.2.5-custom" targetFramework="net461" />
4343
<package id="Serilog" version="2.5.0" targetFramework="net461" />
4444
<package id="SerilogAnalyzer" version="0.12.0.0" targetFramework="net461" />
45+
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
4546
<package id="VSSDK.ComponentModelHost" version="12.0.4" targetFramework="net461" />
4647
<package id="VSSDK.IDE.12" version="12.0.4" targetFramework="net461" />
4748
</packages>

0 commit comments

Comments
 (0)