Merge "Fix comment range parsing for file comments in notedb"

This commit is contained in:
Edwin Kempin
2015-02-03 07:43:18 +00:00
committed by Gerrit Code Review
2 changed files with 31 additions and 2 deletions

View File

@@ -232,7 +232,9 @@ public class CommentsInNotesUtil {
int startLine = RawParseUtils.parseBase10(note, ptr.value, ptr); int startLine = RawParseUtils.parseBase10(note, ptr.value, ptr);
if (startLine == 0) { if (startLine == 0) {
return null; range.setEndLine(0);
ptr.value += 1;
return range;
} }
if (note[ptr.value] == '\n') { if (note[ptr.value] == '\n') {

View File

@@ -812,7 +812,6 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
noteString); noteString);
} }
@Test @Test
public void patchLineCommentMultipleOnePatchsetOneFileBothSides() public void patchLineCommentMultipleOnePatchsetOneFileBothSides()
throws Exception { throws Exception {
@@ -1153,6 +1152,34 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
assertTrue(notes.getDraftPsComments(otherUserId).values().isEmpty()); assertTrue(notes.getDraftPsComments(otherUserId).values().isEmpty());
} }
@Test
public void fileComment() 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, 0, 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)));
}
@Test @Test
public void patchLineCommentNoRange() throws Exception { public void patchLineCommentNoRange() throws Exception {
Change c = newChange(); Change c = newChange();