Fix bug for comments with no range
I forgot to advance the current pointer past the newline character when parsing a comment that had just a line number and not a CommentRange. I added a test for this corner case. Change-Id: I803717e8ea391aa067f40c2d7403f54ee9795733
This commit is contained in:
@@ -239,6 +239,7 @@ public class CommentsInNotesUtil {
|
||||
|
||||
if (note[ptr.value] == '\n') {
|
||||
range.setEndLine(startLine);
|
||||
ptr.value += 1;
|
||||
return range;
|
||||
} else if (note[ptr.value] == ':') {
|
||||
range.setStartLine(startLine);
|
||||
|
||||
@@ -1370,6 +1370,34 @@ public class ChangeNotesTest {
|
||||
assertTrue(notes.getDraftPsComments(otherUserId).values().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patchLineCommentNoRange() throws Exception {
|
||||
Change c = newChange();
|
||||
ChangeUpdate update = newUpdate(c, otherUser);
|
||||
String uuid = "uuid";
|
||||
String messageForBase = "comment for base";
|
||||
Timestamp now = TimeUtil.nowTs();
|
||||
PatchSet.Id psId = c.currentPatchSetId();
|
||||
|
||||
PatchLineComment commentForBase =
|
||||
newPublishedPatchLineComment(psId, "filename", uuid,
|
||||
null, 1, otherUser, null, now, messageForBase,
|
||||
(short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234");
|
||||
update.setPatchSetId(psId);
|
||||
update.upsertComment(commentForBase);
|
||||
update.commit();
|
||||
|
||||
ChangeNotes notes = newNotes(c);
|
||||
Multimap<PatchSet.Id, PatchLineComment> commentsForBase =
|
||||
notes.getBaseComments();
|
||||
Multimap<PatchSet.Id, PatchLineComment> commentsForPs =
|
||||
notes.getPatchSetComments();
|
||||
|
||||
assertTrue(commentsForPs.isEmpty());
|
||||
assertEquals(commentForBase,
|
||||
Iterables.getOnlyElement(commentsForBase.get(psId)));
|
||||
}
|
||||
|
||||
private Change newChange() {
|
||||
return TestChanges.newChange(project, changeOwner);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user