use of com.google.gerrit.extensions.client.SubmitType in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_returnsEmpty_forAbandonedChangeWithPreviouslyStoredSRs.
@Test
public void submitRequirement_returnsEmpty_forAbandonedChangeWithPreviouslyStoredSRs() throws Exception {
for (SubmitType submitType : SubmitType.values()) {
Project.NameKey project = createProjectForPush(submitType);
TestRepository<InMemoryRepository> repo = cloneProject(project);
configSubmitRequirement(project, SubmitRequirement.builder().setName("Code-Review").setSubmittabilityExpression(SubmitRequirementExpression.maxCodeReview()).setAllowOverrideInChildProjects(false).build());
PushOneCommit.Result r = createChange(repo, "master", "Add a file", "foo", "content", "topic");
String changeId = r.getChangeId();
// Abandon change. Submit requirements get stored in the revision note of patch-set 1.
gApi.changes().id(changeId).abandon();
ChangeInfo change = gApi.changes().id(changeId).get();
assertThat(change.submitRequirements).hasSize(1);
assertSubmitRequirementStatus(change.submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
false);
// Clear SRs for the project and update code-review label to be non-blocking.
clearSubmitRequirements(project);
LabelType cr = TestLabels.codeReview().toBuilder().setFunction(LabelFunction.NO_BLOCK).build();
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().upsertLabelType(cr);
u.save();
}
// Restore the change. No SRs apply.
gApi.changes().id(changeId).restore();
change = gApi.changes().id(changeId).get();
assertThat(change.submitRequirements).isEmpty();
// Abandon the change. Still, no SRs apply.
gApi.changes().id(changeId).abandon();
change = gApi.changes().id(changeId).get();
assertThat(change.submitRequirements).isEmpty();
}
}
use of com.google.gerrit.extensions.client.SubmitType in project gerrit by GerritCodeReview.
the class ChangeNotificationsIT method mergeByOwnerAllSubmitStrategies.
private void mergeByOwnerAllSubmitStrategies(boolean advanceBranchBeforeSubmitting) throws Exception {
for (SubmitType submitType : SubmitType.values()) {
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateProject(p -> p.setSubmitType(submitType));
u.save();
}
StagedChange sc = stageChangeReadyForMerge();
String name = submitType + " sender";
if (advanceBranchBeforeSubmitting) {
if (submitType == SubmitType.FAST_FORWARD_ONLY) {
continue;
}
try (Repository repo = repoManager.openRepository(project);
TestRepository<Repository> tr = new TestRepository<>(repo)) {
tr.branch("master").commit().create();
}
name += " after branch has advanced";
}
merge(sc.changeId, sc.owner);
assertWithMessage(name).about(fakeEmailSenders()).that(sender).sent("merged", sc).cc(sc.reviewer, sc.ccer).cc(StagedUsers.REVIEWER_BY_EMAIL, StagedUsers.CC_BY_EMAIL).bcc(sc.starrer).bcc(ALL_COMMENTS, SUBMITTED_CHANGES).noOneElse();
assertWithMessage(name).about(fakeEmailSenders()).that(sender).didNotSend();
}
}
use of com.google.gerrit.extensions.client.SubmitType in project gerrit by GerritCodeReview.
the class ProjectInfoScreen method initProjectOptions.
private void initProjectOptions() {
grid.addHeader(new SmallHeading(AdminConstants.I.headingProjectOptions()));
state = new ListBox();
for (ProjectState stateValue : ProjectState.values()) {
state.addItem(Util.toLongString(stateValue), stateValue.name());
}
saveEnabler.listenTo(state);
grid.add(AdminConstants.I.headingProjectState(), state);
submitType = new ListBox();
for (final SubmitType type : SubmitType.values()) {
submitType.addItem(Util.toLongString(type), type.name());
}
submitType.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
setEnabledForUseContentMerge();
}
});
saveEnabler.listenTo(submitType);
grid.add(AdminConstants.I.headingProjectSubmitType(), submitType);
contentMerge = newInheritedBooleanBox();
saveEnabler.listenTo(contentMerge);
grid.add(AdminConstants.I.useContentMerge(), contentMerge);
newChangeForAllNotInTarget = newInheritedBooleanBox();
saveEnabler.listenTo(newChangeForAllNotInTarget);
grid.add(AdminConstants.I.createNewChangeForAllNotInTarget(), newChangeForAllNotInTarget);
requireChangeID = newInheritedBooleanBox();
saveEnabler.listenTo(requireChangeID);
grid.addHtml(AdminConstants.I.requireChangeID(), requireChangeID);
if (Gerrit.info().receive().enableSignedPush()) {
enableSignedPush = newInheritedBooleanBox();
saveEnabler.listenTo(enableSignedPush);
grid.add(AdminConstants.I.enableSignedPush(), enableSignedPush);
requireSignedPush = newInheritedBooleanBox();
saveEnabler.listenTo(requireSignedPush);
grid.add(AdminConstants.I.requireSignedPush(), requireSignedPush);
}
rejectImplicitMerges = newInheritedBooleanBox();
saveEnabler.listenTo(rejectImplicitMerges);
grid.addHtml(AdminConstants.I.rejectImplicitMerges(), rejectImplicitMerges);
enableReviewerByEmail = newInheritedBooleanBox();
saveEnabler.listenTo(enableReviewerByEmail);
grid.addHtml(AdminConstants.I.enableReviewerByEmail(), enableReviewerByEmail);
maxObjectSizeLimit = new NpTextBox();
saveEnabler.listenTo(maxObjectSizeLimit);
effectiveMaxObjectSizeLimit = new Label();
effectiveMaxObjectSizeLimit.setStyleName(Gerrit.RESOURCES.css().maxObjectSizeLimitEffectiveLabel());
HorizontalPanel p = new HorizontalPanel();
p.add(maxObjectSizeLimit);
p.add(effectiveMaxObjectSizeLimit);
grid.addHtml(AdminConstants.I.headingMaxObjectSizeLimit(), p);
}
use of com.google.gerrit.extensions.client.SubmitType in project gerrit by GerritCodeReview.
the class PRED_project_default_submit_type_1 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
ProjectState projectState = StoredValues.PROJECT_STATE.get(engine);
SubmitType submitType = projectState.getSubmitType();
if (!a1.unify(term[submitType.ordinal()], engine.trail)) {
return engine.fail();
}
return cont;
}
use of com.google.gerrit.extensions.client.SubmitType in project gerrit by GerritCodeReview.
the class MergeOp method validateChangeList.
private BranchBatch validateChangeList(OpenRepo or, Collection<ChangeData> submitted) {
logger.atFine().log("Validating %d changes", submitted.size());
Set<CodeReviewCommit> toSubmit = new LinkedHashSet<>(submitted.size());
SetMultimap<ObjectId, PatchSet.Id> revisions = getRevisions(or, submitted);
SubmitType submitType = null;
ChangeData choseSubmitTypeFrom = null;
for (ChangeData cd : submitted) {
Change.Id changeId = cd.getId();
ChangeNotes notes;
Change chg;
SubmitType st;
try {
notes = cd.notes();
chg = cd.change();
st = getSubmitType(cd);
} catch (StorageException e) {
commitStatus.logProblem(changeId, e);
continue;
}
if (st == null) {
commitStatus.logProblem(changeId, "No submit type for change");
continue;
}
if (submitType == null) {
submitType = st;
choseSubmitTypeFrom = cd;
} else if (st != submitType) {
commitStatus.problem(changeId, String.format("Change has submit type %s, but previously chose submit type %s " + "from change %s in the same batch", st, submitType, choseSubmitTypeFrom.getId()));
continue;
}
if (chg.currentPatchSetId() == null) {
String msg = "Missing current patch set on change";
logger.atSevere().log("%s %s", msg, changeId);
commitStatus.problem(changeId, msg);
continue;
}
PatchSet ps;
BranchNameKey destBranch = chg.getDest();
try {
ps = cd.currentPatchSet();
} catch (StorageException e) {
commitStatus.logProblem(changeId, e);
continue;
}
if (ps == null) {
commitStatus.logProblem(changeId, "Missing patch set on change");
continue;
}
ObjectId id = ps.commitId();
if (!revisions.containsEntry(id, ps.id())) {
if (revisions.containsValue(ps.id())) {
// TODO This is actually an error, the patch set ref exists but points to a revision that
// is different from the revision that we have stored for the patch set in the change
// meta data.
commitStatus.logProblem(changeId, "Revision " + id.name() + " of patch set " + ps.number() + " does not match the revision of the patch set ref " + ps.id().toRefName());
continue;
}
// The patch set ref is not found but we want to merge the change. We can't safely do that
// if the patch set ref is missing. In a cluster setups with multiple primary nodes this can
// indicate a replication lag (e.g. the change meta data was already replicated, but the
// replication of the patch set ref is still pending).
commitStatus.logProblem(changeId, "Patch set ref " + ps.id().toRefName() + " not found. Expected patch set ref of " + ps.number() + " to point to revision " + id.name());
continue;
}
CodeReviewCommit commit;
try {
commit = or.rw.parseCommit(id);
} catch (IOException e) {
commitStatus.logProblem(changeId, e);
continue;
}
commit.setNotes(notes);
commit.setPatchsetId(ps.id());
commitStatus.put(commit);
MergeValidators mergeValidators = mergeValidatorsFactory.create();
try {
mergeValidators.validatePreMerge(or.repo, or.rw, commit, or.project, destBranch, ps.id(), caller);
} catch (MergeValidationException mve) {
commitStatus.problem(changeId, mve.getMessage());
continue;
}
commit.add(or.canMergeFlag);
toSubmit.add(commit);
}
logger.atFine().log("Submitting on this run: %s", toSubmit);
return new AutoValue_MergeOp_BranchBatch(submitType, ImmutableSet.copyOf(toSubmit));
}
Aggregations