Skip to content
Permalink
Browse files
265: Mail bot shows wrong source line for inline review comments
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Aug 31, 2020
1 parent b007595 commit cca94e0a290f6fa3ab17cef5ddf45195b8af1f43
Showing 2 changed files with 3 additions and 4 deletions.
@@ -338,7 +338,7 @@ static String composeReviewComment(PullRequest pr, ReviewComment reviewComment)
body.append(reviewComment.path()).append(" line ").append(reviewComment.line()).append(":\n\n");
try {
var contents = pr.repository().fileContents(reviewComment.path(), reviewComment.hash().hex()).lines().collect(Collectors.toList());
for (int i = Math.max(0, reviewComment.line() - 2); i < Math.min(contents.size(), reviewComment.line() + 1); ++i) {
for (int i = Math.max(0, reviewComment.line() - 3); i < Math.min(contents.size(), reviewComment.line()); ++i) {
body.append("> ").append(i + 1).append(": ").append(contents.get(i)).append("\n");
}
body.append("\n");
@@ -1337,11 +1337,10 @@ void reviewContext(TestInfo testInfo) throws IOException {
TestBotRunner.runPeriodicItems(mlBot);
listServer.processIncoming();

// The archive should only contain context around line 2
// The archive should only contain context up to and including Line 2
Repository.materialize(archiveFolder.path(), archive.url(), "master");
assertTrue(archiveContains(archiveFolder.path(), "^> 2: Line 1$"));
assertTrue(archiveContains(archiveFolder.path(), "^> 3: Line 2$"));
assertFalse(archiveContains(archiveFolder.path(), "^> 4: Line 3$"));
assertFalse(archiveContains(archiveFolder.path(), "^> 3: Line 2$"));
}
}

1 comment on commit cca94e0

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on cca94e0 Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.