Search in sources :

Example 6 with FixInput

use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method extensionApiReturnsUpdatedValueAfterFix.

@Test
public void extensionApiReturnsUpdatedValueAfterFix() throws Exception {
    ChangeNotes notes = insertChange();
    ObjectId commitId = psUtil.current(notes).commitId();
    serverSideTestRepo.branch(notes.getChange().getDest().branch()).update(serverSideTestRepo.getRevWalk().parseCommit(commitId));
    ChangeInfo info = gApi.changes().id(notes.getChangeId().get()).info();
    assertThat(info.status).isEqualTo(ChangeStatus.NEW);
    info = gApi.changes().id(notes.getChangeId().get()).check(new FixInput());
    assertThat(info.status).isEqualTo(ChangeStatus.MERGED);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ObjectId(org.eclipse.jgit.lib.ObjectId) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 7 with FixInput

use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method expectedMergedCommitIsLatestPatchSet.

@Test
public void expectedMergedCommitIsLatestPatchSet() throws Exception {
    ChangeNotes notes = insertChange();
    ObjectId commitId = psUtil.current(notes).commitId();
    serverSideTestRepo.branch(notes.getChange().getDest().branch()).update(serverSideTestRepo.getRevWalk().parseCommit(commitId));
    FixInput fix = new FixInput();
    fix.expectMergedAs = commitId.name();
    assertProblems(notes, fix, problem("Patch set 1 (" + commitId.name() + ") is merged into destination ref" + " refs/heads/master (" + commitId.name() + "), but change status is NEW", FIXED, "Marked change as merged"));
    notes = reload(notes);
    assertThat(notes.getChange().isMerged()).isTrue();
    assertNoProblems(notes, null);
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 8 with FixInput

use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method expectedMergedCommitNotMergedIntoDestination.

@Test
public void expectedMergedCommitNotMergedIntoDestination() throws Exception {
    ChangeNotes notes = insertChange();
    RevCommit commit = serverSideTestRepo.getRevWalk().parseCommit(psUtil.current(notes).commitId());
    serverSideTestRepo.branch(notes.getChange().getDest().branch()).update(commit);
    FixInput fix = new FixInput();
    RevCommit other = serverSideTestRepo.commit().message(commit.getFullMessage()).create();
    fix.expectMergedAs = other.name();
    assertProblems(notes, fix, problem("Expected merged commit " + other.name() + " is not merged into destination ref refs/heads/master" + " (" + commit.name() + ")"));
}
Also used : ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) FixInput(com.google.gerrit.extensions.api.changes.FixInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 9 with FixInput

use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method patchSetMultipleObjectsMissingWithDeletingPatchSets.

@Test
public void patchSetMultipleObjectsMissingWithDeletingPatchSets() throws Exception {
    ChangeNotes notes = insertChange();
    PatchSet ps1 = psUtil.current(notes);
    String rev2 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    PatchSet ps2 = insertMissingPatchSet(notes, rev2);
    notes = incrementPatchSet(reload(notes));
    PatchSet ps3 = psUtil.current(notes);
    String rev4 = "c0ffeeeec0ffeeeec0ffeeeec0ffeeeec0ffeeee";
    PatchSet ps4 = insertMissingPatchSet(notes, rev4);
    notes = reload(notes);
    FixInput fix = new FixInput();
    fix.deletePatchSetIfCommitMissing = true;
    assertProblems(notes, fix, problem("Ref missing: " + ps2.id().toRefName()), problem("Object missing: patch set 2: " + rev2, FIXED, "Deleted patch set"), problem("Ref missing: " + ps4.id().toRefName()), problem("Object missing: patch set 4: " + rev4, FIXED, "Deleted patch set"));
    notes = reload(notes);
    assertThat(notes.getChange().currentPatchSetId().get()).isEqualTo(3);
    assertThat(psUtil.get(notes, ps1.id())).isNotNull();
    assertThat(psUtil.get(notes, ps2.id())).isNull();
    assertThat(psUtil.get(notes, ps3.id())).isNotNull();
    assertThat(psUtil.get(notes, ps4.id())).isNull();
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) TestChanges.newPatchSet(com.google.gerrit.testing.TestChanges.newPatchSet) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 10 with FixInput

use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method expectedMergedCommitIsDanglingPatchSetOlderThanCurrent.

@Test
public void expectedMergedCommitIsDanglingPatchSetOlderThanCurrent() throws Exception {
    ChangeNotes notes = insertChange();
    PatchSet ps1 = psUtil.current(notes);
    // Create dangling ref so next ID in the database becomes 3.
    PatchSet.Id psId2 = PatchSet.id(notes.getChangeId(), 2);
    RevCommit commit2 = patchSetCommit(psId2);
    serverSideTestRepo.branch(psId2.toRefName()).update(commit2);
    notes = incrementPatchSet(notes);
    PatchSet ps3 = psUtil.current(notes);
    assertThat(ps3.id().get()).isEqualTo(3);
    serverSideTestRepo.branch(notes.getChange().getDest().branch()).update(commit2);
    FixInput fix = new FixInput();
    fix.expectMergedAs = commit2.name();
    assertProblems(notes, fix, problem("No patch set found for merged commit " + commit2.name(), FIXED, "Marked change as merged"), problem("Expected merge commit " + commit2.name() + " corresponds to patch set 2," + " not the current patch set 3", FIXED, "Deleted patch set"), problem("Expected merge commit " + commit2.name() + " corresponds to patch set 2," + " not the current patch set 3", FIXED, "Inserted as patch set 4"));
    notes = reload(notes);
    PatchSet.Id psId4 = PatchSet.id(notes.getChangeId(), 4);
    assertThat(notes.getChange().currentPatchSetId()).isEqualTo(psId4);
    assertThat(notes.getChange().isMerged()).isTrue();
    assertThat(psUtil.byChangeAsMap(notes).keySet()).containsExactly(ps1.id(), ps3.id(), psId4);
    assertThat(psUtil.get(notes, psId4).commitId()).isEqualTo(commit2);
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) TestChanges.newPatchSet(com.google.gerrit.testing.TestChanges.newPatchSet) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) FixInput(com.google.gerrit.extensions.api.changes.FixInput) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

FixInput (com.google.gerrit.extensions.api.changes.FixInput)17 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)16 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)16 Test (org.junit.Test)16 PatchSet (com.google.gerrit.entities.PatchSet)10 TestChanges.newPatchSet (com.google.gerrit.testing.TestChanges.newPatchSet)10 RevCommit (org.eclipse.jgit.revwalk.RevCommit)7 ObjectId (org.eclipse.jgit.lib.ObjectId)5 Change (com.google.gerrit.entities.Change)1 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1 ChangeJson (com.google.gerrit.server.change.ChangeJson)1