use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method duplicatePatchSetRevisions.
@Test
public void duplicatePatchSetRevisions() throws Exception {
ChangeNotes notes = insertChange();
PatchSet ps1 = psUtil.current(notes);
notes = incrementPatchSet(notes, serverSideTestRepo.getRevWalk().parseCommit(ps1.commitId()));
assertProblems(notes, null, problem("Multiple patch sets pointing to " + ps1.commitId().name() + ": [1, 2]"));
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method expectedMergedCommitIsOldPatchSetOfSameChange.
@Test
public void expectedMergedCommitIsOldPatchSetOfSameChange() throws Exception {
ChangeNotes notes = insertChange();
ObjectId commitId1 = psUtil.current(notes).commitId();
notes = incrementPatchSet(notes);
PatchSet ps2 = psUtil.current(notes);
serverSideTestRepo.branch(notes.getChange().getDest().branch()).update(serverSideTestRepo.getRevWalk().parseCommit(commitId1));
FixInput fix = new FixInput();
fix.expectMergedAs = commitId1.name();
assertProblems(notes, fix, problem("No patch set found for merged commit " + commitId1.name(), FIXED, "Marked change as merged"), problem("Expected merge commit " + commitId1.name() + " corresponds to patch set 1," + " not the current patch set 2", FIXED, "Deleted patch set"), problem("Expected merge commit " + commitId1.name() + " corresponds to patch set 1," + " not the current patch set 2", FIXED, "Inserted as patch set 3"));
notes = reload(notes);
PatchSet.Id psId3 = PatchSet.id(notes.getChangeId(), 3);
assertThat(notes.getChange().currentPatchSetId()).isEqualTo(psId3);
assertThat(notes.getChange().isMerged()).isTrue();
assertThat(psUtil.byChangeAsMap(notes).keySet()).containsExactly(ps2.id(), psId3);
assertThat(psUtil.get(notes, psId3).commitId()).isEqualTo(commitId1);
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchSetChangeNotes.
@Test
public void patchSetChangeNotes() throws Exception {
Change c = newChange();
// ps1 created by newChange()
ChangeNotes notes = newNotes(c);
PatchSet ps1 = notes.getCurrentPatchSet();
assertThat(notes.getChange().currentPatchSetId()).isEqualTo(ps1.id());
assertThat(notes.getChange().getSubject()).isEqualTo("Change subject");
assertThat(notes.getChange().getOriginalSubject()).isEqualTo("Change subject");
assertThat(ps1.id()).isEqualTo(PatchSet.id(c.getId(), 1));
assertThat(ps1.uploader()).isEqualTo(changeOwner.getAccountId());
// ps2 by other user
RevCommit commit = incrementPatchSet(c, otherUser);
notes = newNotes(c);
PatchSet ps2 = notes.getCurrentPatchSet();
assertThat(ps2.id()).isEqualTo(PatchSet.id(c.getId(), 2));
assertThat(notes.getChange().getSubject()).isEqualTo("PS2");
assertThat(notes.getChange().getOriginalSubject()).isEqualTo("Change subject");
assertThat(notes.getChange().currentPatchSetId()).isEqualTo(ps2.id());
assertThat(ps2.commitId()).isNotEqualTo(ps1.commitId());
assertThat(ps2.commitId()).isEqualTo(commit);
assertThat(ps2.uploader()).isEqualTo(otherUser.getAccountId());
assertThat(ps2.createdOn()).isEqualTo(notes.getChange().getLastUpdatedOn());
// comment on ps1, current patch set is still ps2
ChangeUpdate update = newUpdate(c, changeOwner);
update.setPatchSetId(ps1.id());
update.setChangeMessage("Comment on old patch set.");
update.commit();
notes = newNotes(c);
assertThat(notes.getChange().currentPatchSetId()).isEqualTo(ps2.id());
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ChangeNotesTest method commitChangeNotesUnique.
@Test
public void commitChangeNotesUnique() throws Exception {
// PatchSetId -> ObjectId must be a one to one mapping
Change c = newChange();
ChangeNotes notes = newNotes(c);
PatchSet ps = notes.getCurrentPatchSet();
assertThat(ps).isNotNull();
// new revId for the same patch set, ps1
ChangeUpdate update = newUpdate(c, changeOwner);
RevCommit commit = tr.commit().message("PS1 again").create();
update.setCommit(rw, commit);
update.commit();
StorageException e = assertThrows(StorageException.class, () -> newNotes(c));
assertCause(e, ConfigInvalidException.class, "Multiple revisions parsed for patch set 1:" + " " + commit.name() + " and " + ps.commitId().name());
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class SubmitByRebaseAlwaysIT method rebaseInvokesChangeMessageModifiers.
@Test
public void rebaseInvokesChangeMessageModifiers() throws Throwable {
ChangeMessageModifier modifier1 = (msg, orig, tip, dest) -> msg + "This-change-before-rebase: " + orig.name() + "\n";
ChangeMessageModifier modifier2 = (msg, orig, tip, dest) -> msg + "Previous-step-tip: " + tip.name() + "\n";
ChangeMessageModifier modifier3 = (msg, orig, tip, dest) -> msg + "Dest: " + dest.shortName() + "\n";
try (Registration registration = extensionRegistry.newRegistration().add(modifier1).add(modifier2).add(modifier3)) {
ImmutableList<PushOneCommit.Result> changes = submitWithRebase(admin);
ChangeData cd1 = changes.get(0).getChange();
ChangeData cd2 = changes.get(1).getChange();
assertThat(cd2.patchSets()).hasSize(2);
String change1CurrentCommit = cd1.currentPatchSet().commitId().name();
String change2Ps1Commit = cd2.patchSet(PatchSet.id(cd2.getId(), 1)).commitId().name();
assertThat(gApi.changes().id(cd2.getId().get()).revision(2).commit(false).message).isEqualTo("Change 2\n\n" + ("Change-Id: " + cd2.change().getKey() + "\n") + ("Reviewed-on: " + urlFormatter.get().getChangeViewUrl(project, cd2.getId()).get() + "\n") + "Reviewed-by: Administrator <admin@example.com>\n" + ("This-change-before-rebase: " + change2Ps1Commit + "\n") + ("Previous-step-tip: " + change1CurrentCommit + "\n") + "Dest: master\n");
}
}
Aggregations