Add project config boolean to require signed push on a project

This is controlled by receive.requireSignedPush in the project.config,
which is a separate bit from receive.enableSignedPush. (Adding an
inheritable tri-state enum would have been complex to implement and
have hard-to-define semantics.)

requireSignedPush is only inspected if enableSignedPush is true; this
allows project owners to temporarily disable signed push entirely e.g.
due to a bug, without having to flip both bits.

Change-Id: I07999b6fa185d470b30509941473e3158f9dfa2c
This commit is contained in:
Dave Borowitz
2015-10-20 10:35:26 -04:00
parent ff473bb345
commit 0543c735eb
14 changed files with 117 additions and 11 deletions

View File

@@ -43,6 +43,7 @@ public interface AdminConstants extends Constants {
String useSignedOffBy();
String createNewChangeForAllNotInTarget();
String enableSignedPush();
String requireSignedPush();
String requireChangeID();
String headingMaxObjectSizeLimit();
String headingGroupOptions();

View File

@@ -25,6 +25,7 @@ useContributorAgreements = Require a valid contributor agreement to upload
useSignedOffBy = Require <code>Signed-off-by</code> in commit message
createNewChangeForAllNotInTarget = Create a new change for every commit not in the target branch
enableSignedPush = Enable signed push
requireSignedPush = Require signed push
requireChangeID = Require <code>Change-Id</code> in commit message
headingMaxObjectSizeLimit = Maximum Git object size limit
headingGroupOptions = Group Options

View File

@@ -84,6 +84,7 @@ public class ProjectInfoScreen extends ProjectScreen {
private ListBox contentMerge;
private ListBox newChangeForAllNotInTarget;
private ListBox enableSignedPush;
private ListBox requireSignedPush;
private NpTextBox maxObjectSizeLimit;
private Label effectiveMaxObjectSizeLimit;
private Map<String, Map<String, HasEnabled>> pluginConfigWidgets;
@@ -247,6 +248,9 @@ public class ProjectInfoScreen extends ProjectScreen {
enableSignedPush = newInheritedBooleanBox();
saveEnabler.listenTo(enableSignedPush);
grid.add(Util.C.enableSignedPush(), enableSignedPush);
requireSignedPush = newInheritedBooleanBox();
saveEnabler.listenTo(requireSignedPush);
grid.add(Util.C.requireSignedPush(), requireSignedPush);
}
maxObjectSizeLimit = new NpTextBox();
@@ -326,6 +330,9 @@ public class ProjectInfoScreen extends ProjectScreen {
}
private void setBool(ListBox box, InheritedBooleanInfo inheritedBoolean) {
if (box == null) {
return;
}
int inheritedIndex = -1;
for (int i = 0; i < box.getItemCount(); i++) {
if (box.getValue(i).startsWith(InheritableBoolean.INHERIT.name())) {
@@ -372,8 +379,9 @@ public class ProjectInfoScreen extends ProjectScreen {
setBool(contentMerge, result.useContentMerge());
setBool(newChangeForAllNotInTarget, result.createNewChangeForAllNotInTarget());
setBool(requireChangeID, result.requireChangeId());
if (enableSignedPush != null) {
if (Gerrit.info().receive().enableSignedPush()) {
setBool(enableSignedPush, result.enableSignedPush());
setBool(requireSignedPush, result.requireSignedPush());
}
setSubmitType(result.submitType());
setState(result.state());
@@ -644,12 +652,14 @@ public class ProjectInfoScreen extends ProjectScreen {
private void doSave() {
enableForm(false);
saveProject.setEnabled(false);
InheritableBoolean sp = enableSignedPush != null
InheritableBoolean esp = enableSignedPush != null
? getBool(enableSignedPush) : null;
InheritableBoolean rsp = requireSignedPush != null
? getBool(requireSignedPush) : null;
ProjectApi.setConfig(getProjectKey(), descTxt.getText().trim(),
getBool(contributorAgreements), getBool(contentMerge),
getBool(signedOffBy), getBool(newChangeForAllNotInTarget), getBool(requireChangeID),
sp,
esp, rsp,
maxObjectSizeLimit.getText().trim(),
SubmitType.valueOf(submitType.getValue(submitType.getSelectedIndex())),
ProjectState.valueOf(state.getValue(state.getSelectedIndex())),