use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class PortedCommentsIT method commentOnFirstParentIsPortedToNewPosition.
@Test
public void commentOnFirstParentIsPortedToNewPosition() throws Exception {
// Set up change and patchsets.
Change.Id parent1ChangeId = changeOps.newChange().file("file1").content("Line 1\n").create();
Change.Id parent2ChangeId = changeOps.newChange().file("file2").content("Line 1\n").create();
Change.Id childChangeId = changeOps.newChange().mergeOf().change(parent1ChangeId).and().change(parent2ChangeId).file("file1").content("Line one\n").create();
PatchSet.Id childPatchset1Id = changeOps.change(childChangeId).currentPatchset().get().patchsetId();
PatchSet.Id parent1Patchset2Id = changeOps.change(parent1ChangeId).newPatchset().file("file1").content("Line 0\nLine 1\n").create();
PatchSet.Id childPatchset2Id = changeOps.change(childChangeId).newPatchset().parents().patchset(parent1Patchset2Id).and().change(parent2ChangeId).create();
// Add comment.
String commentUuid = newComment(childPatchset1Id).onParentCommit().onLine(1).ofFile("file1").create();
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
assertThat(portedComment).line().isEqualTo(2);
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class PortedCommentsIT method portedCommentHasOriginalPatchset.
@Test
public void portedCommentHasOriginalPatchset() throws Exception {
// Set up change and patchsets.
Change.Id changeId = changeOps.newChange().create();
PatchSet.Id patchset1Id = changeOps.change(changeId).currentPatchset().get().patchsetId();
PatchSet.Id patchset2Id = changeOps.change(changeId).newPatchset().create();
// Add comment.
String commentUuid = newComment(patchset1Id).create();
CommentInfo portedComment = getPortedComment(patchset2Id, commentUuid);
assertThat(portedComment).patchSet().isEqualTo(patchset1Id.get());
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class PortedCommentsIT method commentOnSecondParentIsPortedToNewPosition.
@Test
public void commentOnSecondParentIsPortedToNewPosition() throws Exception {
// Set up change and patchsets.
Change.Id parent1ChangeId = changeOps.newChange().file("file1").content("Line 1\n").create();
Change.Id parent2ChangeId = changeOps.newChange().file("file2").content("Line 1\n").create();
Change.Id childChangeId = changeOps.newChange().mergeOf().change(parent1ChangeId).and().change(parent2ChangeId).file("file2").content("Line one\n").create();
PatchSet.Id childPatchset1Id = changeOps.change(childChangeId).currentPatchset().get().patchsetId();
PatchSet.Id parent2Patchset2Id = changeOps.change(parent1ChangeId).newPatchset().file("file2").content("Line 0\nLine 1\n").create();
PatchSet.Id childPatchset2Id = changeOps.change(childChangeId).newPatchset().parents().change(parent1ChangeId).and().patchset(parent2Patchset2Id).create();
// Add comment.
String commentUuid = newComment(childPatchset1Id).onSecondParentCommit().onLine(1).ofFile("file2").create();
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
assertThat(portedComment).line().isEqualTo(2);
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class PortedCommentsIT method commentOnFirstParentIsPortedToSingleParentWhenPatchsetChangedToNonMergeCommit.
@Test
public void commentOnFirstParentIsPortedToSingleParentWhenPatchsetChangedToNonMergeCommit() throws Exception {
// Set up change and patchsets.
Change.Id parent1ChangeId = changeOps.newChange().file("file1").content("Line 1\n").create();
Change.Id parent2ChangeId = changeOps.newChange().file("file2").content("Line 1\n").create();
Change.Id childChangeId = changeOps.newChange().mergeOf().change(parent1ChangeId).and().change(parent2ChangeId).create();
PatchSet.Id childPatchset1Id = changeOps.change(childChangeId).currentPatchset().get().patchsetId();
PatchSet.Id parent1PatchsetId2 = changeOps.change(parent1ChangeId).newPatchset().file("file1").content("Line 0\nLine 1\n").create();
PatchSet.Id childPatchset2Id = changeOps.change(childChangeId).newPatchset().parent().patchset(parent1PatchsetId2).create();
// Add comment.
String commentUuid = newComment(childPatchset1Id).onParentCommit().onLine(1).ofFile("file1").create();
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
assertThat(portedComment).line().isEqualTo(2);
assertThat(portedComment).side().isEqualTo(Side.PARENT);
assertThat(portedComment).parent().isEqualTo(1);
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class PortedCommentsIT method commentOnAutoMergeCommitIsPortedToNewPosition.
@Test
public void commentOnAutoMergeCommitIsPortedToNewPosition() throws Exception {
// Set up change and patchsets. Use the same file so that there's a meaningful auto-merge
// commit/diff.
Change.Id parent1ChangeId = changeOps.newChange().file("file1").content("Line 1\n").create();
Change.Id parent2ChangeId = changeOps.newChange().file("file1").content("Line 1\n").create();
Change.Id childChangeId = changeOps.newChange().mergeOf().change(parent1ChangeId).and().change(parent2ChangeId).create();
PatchSet.Id childPatchset1Id = changeOps.change(childChangeId).currentPatchset().get().patchsetId();
PatchSet.Id parent1Patchset2Id = changeOps.change(parent1ChangeId).newPatchset().file("file1").content("Line 0\nLine 1\n").create();
PatchSet.Id parent2Patchset2Id = changeOps.change(parent1ChangeId).newPatchset().file("file1").content("Line zero\nLine 1\n").create();
PatchSet.Id childPatchset2Id = changeOps.change(childChangeId).newPatchset().parents().patchset(parent1Patchset2Id).and().patchset(parent2Patchset2Id).create();
// Add comment.
String commentUuid = newComment(childPatchset1Id).onAutoMergeCommit().onLine(1).ofFile("file1").create();
CommentInfo portedComment = getPortedComment(childPatchset2Id, commentUuid);
// Merging the parents creates a conflict in the file. -> Several lines are added due to
// conflict markers in the auto-merge commit. We don't care about the exact number, just that
// the comment moved down several lines (instead of just one in each parent) and that the
// porting logic hence used the auto-merge commit for its computation.
assertThat(portedComment).line().isGreaterThan(2);
}
Aggregations