Search in sources :

Example 1 with ChangeKind

use of com.google.gerrit.extensions.client.ChangeKind in project gerrit by GerritCodeReview.

the class StickyApprovalsIT method removedVotesNotSticky.

@Test
public void removedVotesNotSticky() throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    cfg.getLabelSections().get("Code-Review").setCopyAllScoresOnTrivialRebase(true);
    cfg.getLabelSections().get("Verified").setCopyAllScoresIfNoCodeChange(true);
    saveProjectConfig(project, cfg);
    for (ChangeKind changeKind : EnumSet.of(REWORK, TRIVIAL_REBASE, NO_CODE_CHANGE, MERGE_FIRST_PARENT_UPDATE, NO_CHANGE)) {
        testRepo.reset(getRemoteHead());
        String changeId = createChange(changeKind);
        vote(admin, changeId, 2, 1);
        vote(user, changeId, -2, -1);
        // Remove votes by re-voting with 0
        vote(admin, changeId, 0, 0);
        vote(user, changeId, 0, 0);
        ChangeInfo c = detailedChange(changeId);
        assertVotes(c, admin, 0, 0, null);
        assertVotes(c, user, 0, 0, null);
        updateChange(changeId, changeKind);
        c = detailedChange(changeId);
        assertVotes(c, admin, 0, 0, changeKind);
        assertVotes(c, user, 0, 0, changeKind);
    }
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeKind(com.google.gerrit.extensions.client.ChangeKind) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with ChangeKind

use of com.google.gerrit.extensions.client.ChangeKind in project gerrit by GerritCodeReview.

the class StickyApprovalsIT method stickyOnMinScore.

@Test
public void stickyOnMinScore() throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    cfg.getLabelSections().get("Code-Review").setCopyMinScore(true);
    saveProjectConfig(project, cfg);
    for (ChangeKind changeKind : EnumSet.of(REWORK, TRIVIAL_REBASE, NO_CODE_CHANGE, MERGE_FIRST_PARENT_UPDATE, NO_CHANGE)) {
        testRepo.reset(getRemoteHead());
        String changeId = createChange(changeKind);
        vote(admin, changeId, -1, 1);
        vote(user, changeId, -2, -1);
        updateChange(changeId, changeKind);
        ChangeInfo c = detailedChange(changeId);
        assertVotes(c, admin, 0, 0, changeKind);
        assertVotes(c, user, -2, 0, changeKind);
    }
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeKind(com.google.gerrit.extensions.client.ChangeKind) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with ChangeKind

use of com.google.gerrit.extensions.client.ChangeKind in project gerrit by GerritCodeReview.

the class ChangeKindCacheImpl method getChangeKindInternal.

private static ChangeKind getChangeKindInternal(ChangeKindCache cache, @Nullable RevWalk rw, @Nullable Config repoConfig, ChangeData change, PatchSet patch) {
    ChangeKind kind = ChangeKind.REWORK;
    // the repository.
    if (patch.getId().get() > 1) {
        try {
            Collection<PatchSet> patchSetCollection = change.patchSets();
            PatchSet priorPs = patch;
            for (PatchSet ps : patchSetCollection) {
                if (ps.getId().get() < patch.getId().get() && (ps.getId().get() > priorPs.getId().get() || priorPs == patch)) {
                    // We only want the previous patch set, so walk until the last one
                    priorPs = ps;
                }
            }
            // and deletes the draft.
            if (priorPs != patch) {
                kind = cache.getChangeKind(change.project(), rw, repoConfig, ObjectId.fromString(priorPs.getRevision().get()), ObjectId.fromString(patch.getRevision().get()));
            }
        } catch (OrmException e) {
            // Do nothing; assume we have a complex change
            log.warn("Unable to get change kind for patchSet " + patch.getPatchSetId() + "of change " + change.getId(), e);
        }
    }
    return kind;
}
Also used : OrmException(com.google.gwtorm.server.OrmException) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ChangeKind(com.google.gerrit.extensions.client.ChangeKind)

Example 4 with ChangeKind

use of com.google.gerrit.extensions.client.ChangeKind in project gerrit by GerritCodeReview.

the class StickyApprovalsIT method assertNotSticky.

private void assertNotSticky(Set<ChangeKind> changeKinds) throws Exception {
    for (ChangeKind changeKind : changeKinds) {
        testRepo.reset(getRemoteHead());
        String changeId = createChange(changeKind);
        vote(admin, changeId, +2, 1);
        vote(user, changeId, -2, -1);
        updateChange(changeId, changeKind);
        ChangeInfo c = detailedChange(changeId);
        assertVotes(c, admin, 0, 0, changeKind);
        assertVotes(c, user, 0, 0, changeKind);
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeKind(com.google.gerrit.extensions.client.ChangeKind)

Example 5 with ChangeKind

use of com.google.gerrit.extensions.client.ChangeKind in project gerrit by GerritCodeReview.

the class StickyApprovalsIT method stickyOnMaxScore.

@Test
public void stickyOnMaxScore() throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    cfg.getLabelSections().get("Code-Review").setCopyMaxScore(true);
    saveProjectConfig(project, cfg);
    for (ChangeKind changeKind : EnumSet.of(REWORK, TRIVIAL_REBASE, NO_CODE_CHANGE, MERGE_FIRST_PARENT_UPDATE, NO_CHANGE)) {
        testRepo.reset(getRemoteHead());
        String changeId = createChange(changeKind);
        vote(admin, changeId, 2, 1);
        vote(user, changeId, 1, -1);
        updateChange(changeId, changeKind);
        ChangeInfo c = detailedChange(changeId);
        assertVotes(c, admin, 2, 0, changeKind);
        assertVotes(c, user, 0, 0, changeKind);
    }
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeKind(com.google.gerrit.extensions.client.ChangeKind) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ChangeKind (com.google.gerrit.extensions.client.ChangeKind)7 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)3 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)3 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)3 OrmException (com.google.gwtorm.server.OrmException)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 ObjectId (org.eclipse.jgit.lib.ObjectId)2 Repository (org.eclipse.jgit.lib.Repository)2 RevWalk (org.eclipse.jgit.revwalk.RevWalk)2 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 Change (com.google.gerrit.reviewdb.client.Change)1 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)1 PatchSetInserter (com.google.gerrit.server.change.PatchSetInserter)1 NoSuchChangeException (com.google.gerrit.server.project.NoSuchChangeException)1 ProjectState (com.google.gerrit.server.project.ProjectState)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1