Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

265: Mail bot shows wrong source line for inline review comments #757

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -334,7 +334,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$"));
}
}