use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method patchSetObjectAndRefMissingWithFix.
@Test
public void patchSetObjectAndRefMissingWithFix() throws Exception {
String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
ChangeNotes notes = insertChange();
PatchSet ps = insertMissingPatchSet(notes, rev);
notes = reload(notes);
String refName = ps.id().toRefName();
assertProblems(notes, new FixInput(), problem("Ref missing: " + refName), problem("Object missing: patch set 2: " + rev));
}
use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method onlyPatchSetObjectMissingWithFix.
@Test
public void onlyPatchSetObjectMissingWithFix() throws Exception {
Change c = TestChanges.newChange(project, admin.id(), sequences.nextChangeId());
PatchSet.Id psId = c.currentPatchSetId();
String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
PatchSet ps = newPatchSet(psId, rev, adminId);
addNoteDbCommit(c.getId(), "Create change\n" + "\n" + "Patch-set: 1\n" + "Branch: " + c.getDest().branch() + "\n" + "Change-id: " + c.getKey().get() + "\n" + "Subject: Bogus subject\n" + "Commit: " + rev + "\n" + "Groups: " + rev + "\n");
ChangeNotes notes = changeNotesFactory.create(c.getProject(), c.getId());
FixInput fix = new FixInput();
fix.deletePatchSetIfCommitMissing = true;
assertProblems(notes, fix, problem("Ref missing: " + ps.id().toRefName()), problem("Object missing: patch set 1: " + rev, FIX_FAILED, "Cannot delete patch set; no patch sets would remain"));
notes = reload(notes);
assertThat(notes.getChange().currentPatchSetId().get()).isEqualTo(1);
assertThat(psUtil.current(notes)).isNotNull();
}
use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method patchSetRefMissingWithFix.
@Test
public void patchSetRefMissingWithFix() throws Exception {
ChangeNotes notes = insertChange();
ObjectId commitId = psUtil.current(notes).commitId();
serverSideTestRepo.update("refs/other/foo", commitId);
String refName = notes.getChange().currentPatchSetId().toRefName();
deleteRef(refName);
assertProblems(notes, new FixInput(), problem("Ref missing: " + refName, FIXED, "Repaired patch set ref"));
assertThat(serverSideTestRepo.getRepository().exactRef(refName).getObjectId()).isEqualTo(commitId);
}
use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method createNewPatchSetForExpectedMergeCommitWithChangeId.
@Test
public void createNewPatchSetForExpectedMergeCommitWithChangeId() throws Exception {
ChangeNotes notes = insertChange();
String dest = notes.getChange().getDest().branch();
RevCommit commit = serverSideTestRepo.getRevWalk().parseCommit(psUtil.current(notes).commitId());
RevCommit mergedAs = serverSideTestRepo.commit().parent(commit.getParent(0)).message(commit.getShortMessage() + "\n" + "\n" + "Change-Id: " + notes.getChange().getKey().get() + "\n").create();
serverSideTestRepo.getRevWalk().parseBody(mergedAs);
assertThat(mergedAs.getFooterLines(FooterConstants.CHANGE_ID)).containsExactly(notes.getChange().getKey().get());
serverSideTestRepo.update(dest, mergedAs);
assertNoProblems(notes, null);
FixInput fix = new FixInput();
fix.expectMergedAs = mergedAs.name();
assertProblems(notes, fix, problem("No patch set found for merged commit " + mergedAs.name(), FIXED, "Marked change as merged"), problem("Expected merged commit " + mergedAs.name() + " has no associated patch set", FIXED, "Inserted as patch set 2"));
notes = reload(notes);
PatchSet.Id psId2 = PatchSet.id(notes.getChangeId(), 2);
assertThat(notes.getChange().currentPatchSetId()).isEqualTo(psId2);
assertThat(psUtil.get(notes, psId2).commitId()).isEqualTo(mergedAs);
assertNoProblems(notes, null);
}
use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method expectedMergedCommitMatchesMultiplePatchSets.
@Test
public void expectedMergedCommitMatchesMultiplePatchSets() throws Exception {
ChangeNotes notes1 = insertChange();
PatchSet.Id psId1 = psUtil.current(notes1).id();
String dest = notes1.getChange().getDest().branch();
RevCommit commit = serverSideTestRepo.getRevWalk().parseCommit(psUtil.current(notes1).commitId());
serverSideTestRepo.branch(dest).update(commit);
ChangeNotes notes2 = insertChange();
notes2 = incrementPatchSet(notes2, commit);
PatchSet.Id psId2 = psUtil.current(notes2).id();
ChangeNotes notes3 = insertChange();
notes3 = incrementPatchSet(notes3, commit);
PatchSet.Id psId3 = psUtil.current(notes3).id();
FixInput fix = new FixInput();
fix.expectMergedAs = commit.name();
assertProblems(notes1, fix, problem("Multiple patch sets for expected merged commit " + commit.name() + ": [" + psId1 + ", " + psId2 + ", " + psId3 + "]"));
}
Aggregations