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);
}
}
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);
}
}
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;
}
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);
}
}
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);
}
}
Aggregations