Return more project settings from /project/*/config
Include the project state, the default submit type and the max object size limit into the result of the /projects/*/config REST endpoint. Change-Id: I5228cf7c11646b74234b8edd49ba1f76c965239d
This commit is contained in:

committed by
Edwin Kempin

parent
3660c135be
commit
3c99f596c9
@@ -455,7 +455,14 @@ read access to `refs/meta/config`.
|
|||||||
"value": false,
|
"value": false,
|
||||||
"configured_value": "FALSE",
|
"configured_value": "FALSE",
|
||||||
"inherited_value": true
|
"inherited_value": true
|
||||||
}
|
},
|
||||||
|
"max_object_size_limit": {
|
||||||
|
"value": "15m",
|
||||||
|
"configured_value": "15m",
|
||||||
|
"inherited_value": "20m"
|
||||||
|
},
|
||||||
|
"submit_type": "MERGE_IF_NECESSARY",
|
||||||
|
"state": "ACTIVE",
|
||||||
"commentlinks": {}
|
"commentlinks": {}
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
@@ -1086,6 +1093,17 @@ link:#inherited-boolean-info[InheritedBooleanInfo] that tells whether a
|
|||||||
valid link:user-changeid.html[Change-Id] footer in any commit uploaded
|
valid link:user-changeid.html[Change-Id] footer in any commit uploaded
|
||||||
for review is required. This does not apply to commits pushed directly
|
for review is required. This does not apply to commits pushed directly
|
||||||
to a branch or tag.
|
to a branch or tag.
|
||||||
|
|`max_object_size_limit` ||
|
||||||
|
The link:config-gerrit.html#receive.maxObjectSizeLimit[max object size
|
||||||
|
limit] of this project as a link:#max-object-size-limit-info[
|
||||||
|
MaxObjectSizeLimitInfo] entity.
|
||||||
|
|`submit_type` ||
|
||||||
|
The default submit type of the project, can be `MERGE_IF_NECESSARY`,
|
||||||
|
`FAST_FORWARD_ONLY`, `REBASE_IF_NECESSARY`, `MERGE_ALWAYS` or
|
||||||
|
`CHERRY_PICK`.
|
||||||
|
|`state` |optional|
|
||||||
|
The state of the project, can be `ACTIVE`, `READ_ONLY` or `HIDDEN`. +
|
||||||
|
Not set if the project state is `ACTIVE`.
|
||||||
|`commentlinks` ||
|
|`commentlinks` ||
|
||||||
Map with the comment link configurations of the project. The name of
|
Map with the comment link configurations of the project. The name of
|
||||||
the comment link configuration is mapped to the comment link
|
the comment link configuration is mapped to the comment link
|
||||||
@@ -1196,6 +1214,29 @@ The boolean value inherited from the parent. +
|
|||||||
Not set if there is no parent.
|
Not set if there is no parent.
|
||||||
|================================
|
|================================
|
||||||
|
|
||||||
|
[[max-object-size-limit-info]]
|
||||||
|
MaxObjectSizeLimitInfo
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
The `MaxObjectSizeLimitInfo` entity contains information about the
|
||||||
|
link:config-gerrit.html#receive.maxObjectSizeLimit[max object size
|
||||||
|
limit] of a project.
|
||||||
|
|
||||||
|
[options="header",width="50%",cols="1,^2,4"]
|
||||||
|
|===============================
|
||||||
|
|Field Name ||Description
|
||||||
|
|`value` |optional|
|
||||||
|
The effective value of the max object size limit as a formatted string. +
|
||||||
|
Not set if there is no limit for the object size.
|
||||||
|
|`configured_value`|optional|
|
||||||
|
The max object size limit that is configured on the project as a
|
||||||
|
formatted string. +
|
||||||
|
Not set if there is no limit for the object size configured on project
|
||||||
|
level.
|
||||||
|
|`inherited_value` |optional|
|
||||||
|
The max object size limit that is inherited as a formatted string. +
|
||||||
|
Not set if there is no global limit for the object size.
|
||||||
|
|===============================
|
||||||
|
|
||||||
[[project-description-input]]
|
[[project-description-input]]
|
||||||
ProjectDescriptionInput
|
ProjectDescriptionInput
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.git;
|
|||||||
|
|
||||||
import com.google.gerrit.server.config.ConfigUtil;
|
import com.google.gerrit.server.config.ConfigUtil;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@@ -29,12 +30,14 @@ public class TransferConfig {
|
|||||||
private final int timeout;
|
private final int timeout;
|
||||||
private final PackConfig packConfig;
|
private final PackConfig packConfig;
|
||||||
private final long maxObjectSizeLimit;
|
private final long maxObjectSizeLimit;
|
||||||
|
private final String maxObjectSizeLimitFormatted;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TransferConfig(@GerritServerConfig final Config cfg) {
|
TransferConfig(@GerritServerConfig final Config cfg) {
|
||||||
timeout = (int) ConfigUtil.getTimeUnit(cfg, "transfer", null, "timeout", //
|
timeout = (int) ConfigUtil.getTimeUnit(cfg, "transfer", null, "timeout", //
|
||||||
0, TimeUnit.SECONDS);
|
0, TimeUnit.SECONDS);
|
||||||
maxObjectSizeLimit = cfg.getLong("receive", "maxObjectSizeLimit", 0);
|
maxObjectSizeLimit = cfg.getLong("receive", "maxObjectSizeLimit", 0);
|
||||||
|
maxObjectSizeLimitFormatted = cfg.getString("receive", null, "maxObjectSizeLimit");
|
||||||
|
|
||||||
packConfig = new PackConfig();
|
packConfig = new PackConfig();
|
||||||
packConfig.setDeltaCompress(false);
|
packConfig.setDeltaCompress(false);
|
||||||
@@ -54,4 +57,19 @@ public class TransferConfig {
|
|||||||
public long getMaxObjectSizeLimit() {
|
public long getMaxObjectSizeLimit() {
|
||||||
return maxObjectSizeLimit;
|
return maxObjectSizeLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFormattedMaxObjectSizeLimit() {
|
||||||
|
return maxObjectSizeLimitFormatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getEffectiveMaxObjectSizeLimit(ProjectState p) {
|
||||||
|
long global = getMaxObjectSizeLimit();
|
||||||
|
long local = p.getMaxObjectSizeLimit();
|
||||||
|
if (global > 0 && local > 0) {
|
||||||
|
return Math.min(global, local);
|
||||||
|
} else {
|
||||||
|
// zero means "no limit", in this case the max is more limiting
|
||||||
|
return Math.max(global, local);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,15 +19,26 @@ import com.google.common.collect.Maps;
|
|||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||||
|
import com.google.gerrit.server.git.TransferConfig;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GetConfig implements RestReadView<ProjectResource> {
|
public class GetConfig implements RestReadView<ProjectResource> {
|
||||||
|
|
||||||
|
private final TransferConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public GetConfig(TransferConfig config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigInfo apply(ProjectResource resource) {
|
public ConfigInfo apply(ProjectResource resource) {
|
||||||
ConfigInfo result = new ConfigInfo();
|
ConfigInfo result = new ConfigInfo();
|
||||||
ProjectState state = resource.getControl().getProjectState();
|
ProjectState state = resource.getControl().getProjectState();
|
||||||
|
Project p = state.getProject();
|
||||||
InheritedBooleanInfo useContributorAgreements = new InheritedBooleanInfo();
|
InheritedBooleanInfo useContributorAgreements = new InheritedBooleanInfo();
|
||||||
InheritedBooleanInfo useSignedOffBy = new InheritedBooleanInfo();
|
InheritedBooleanInfo useSignedOffBy = new InheritedBooleanInfo();
|
||||||
InheritedBooleanInfo useContentMerge = new InheritedBooleanInfo();
|
InheritedBooleanInfo useContentMerge = new InheritedBooleanInfo();
|
||||||
@@ -38,7 +49,6 @@ public class GetConfig implements RestReadView<ProjectResource> {
|
|||||||
useContentMerge.value = state.isUseContentMerge();
|
useContentMerge.value = state.isUseContentMerge();
|
||||||
requireChangeId.value = state.isRequireChangeID();
|
requireChangeId.value = state.isRequireChangeID();
|
||||||
|
|
||||||
Project p = state.getProject();
|
|
||||||
useContributorAgreements.configuredValue = p.getUseContributorAgreements();
|
useContributorAgreements.configuredValue = p.getUseContributorAgreements();
|
||||||
useSignedOffBy.configuredValue = p.getUseSignedOffBy();
|
useSignedOffBy.configuredValue = p.getUseSignedOffBy();
|
||||||
useContentMerge.configuredValue = p.getUseContentMerge();
|
useContentMerge.configuredValue = p.getUseContentMerge();
|
||||||
@@ -57,6 +67,18 @@ public class GetConfig implements RestReadView<ProjectResource> {
|
|||||||
result.useContentMerge = useContentMerge;
|
result.useContentMerge = useContentMerge;
|
||||||
result.requireChangeId = requireChangeId;
|
result.requireChangeId = requireChangeId;
|
||||||
|
|
||||||
|
MaxObjectSizeLimitInfo maxObjectSizeLimit = new MaxObjectSizeLimitInfo();
|
||||||
|
maxObjectSizeLimit.value =
|
||||||
|
config.getEffectiveMaxObjectSizeLimit(state) == config.getMaxObjectSizeLimit()
|
||||||
|
? config.getFormattedMaxObjectSizeLimit()
|
||||||
|
: p.getMaxObjectSizeLimit();
|
||||||
|
maxObjectSizeLimit.configuredValue = p.getMaxObjectSizeLimit();
|
||||||
|
maxObjectSizeLimit.inheritedValue = config.getFormattedMaxObjectSizeLimit();
|
||||||
|
result.maxObjectSizeLimit = maxObjectSizeLimit;
|
||||||
|
|
||||||
|
result.submitType = p.getSubmitType();
|
||||||
|
result.state = p.getState() != Project.State.ACTIVE ? p.getState() : null;
|
||||||
|
|
||||||
result.commentlinks = Maps.newLinkedHashMap();
|
result.commentlinks = Maps.newLinkedHashMap();
|
||||||
for (CommentLinkInfo cl : state.getCommentLinks()) {
|
for (CommentLinkInfo cl : state.getCommentLinks()) {
|
||||||
result.commentlinks.put(cl.name, cl);
|
result.commentlinks.put(cl.name, cl);
|
||||||
@@ -73,6 +95,9 @@ public class GetConfig implements RestReadView<ProjectResource> {
|
|||||||
public InheritedBooleanInfo useContentMerge;
|
public InheritedBooleanInfo useContentMerge;
|
||||||
public InheritedBooleanInfo useSignedOffBy;
|
public InheritedBooleanInfo useSignedOffBy;
|
||||||
public InheritedBooleanInfo requireChangeId;
|
public InheritedBooleanInfo requireChangeId;
|
||||||
|
public MaxObjectSizeLimitInfo maxObjectSizeLimit;
|
||||||
|
public SubmitType submitType;
|
||||||
|
public Project.State state;
|
||||||
|
|
||||||
public Map<String, CommentLinkInfo> commentlinks;
|
public Map<String, CommentLinkInfo> commentlinks;
|
||||||
public ThemeInfo theme;
|
public ThemeInfo theme;
|
||||||
@@ -83,4 +108,10 @@ public class GetConfig implements RestReadView<ProjectResource> {
|
|||||||
public InheritableBoolean configuredValue;
|
public InheritableBoolean configuredValue;
|
||||||
public Boolean inheritedValue;
|
public Boolean inheritedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MaxObjectSizeLimitInfo {
|
||||||
|
public String value;
|
||||||
|
public String configuredValue;
|
||||||
|
public String inheritedValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,8 @@ final class Receive extends AbstractGitCommand {
|
|||||||
final ReceivePack rp = receive.getReceivePack();
|
final ReceivePack rp = receive.getReceivePack();
|
||||||
rp.setRefLogIdent(currentUser.newRefLogIdent());
|
rp.setRefLogIdent(currentUser.newRefLogIdent());
|
||||||
rp.setTimeout(config.getTimeout());
|
rp.setTimeout(config.getTimeout());
|
||||||
rp.setMaxObjectSizeLimit(getMaxObjectSizeLimit());
|
rp.setMaxObjectSizeLimit(config.getEffectiveMaxObjectSizeLimit(
|
||||||
|
projectControl.getProjectState()));
|
||||||
try {
|
try {
|
||||||
receive.advertiseHistory();
|
receive.advertiseHistory();
|
||||||
rp.receive(in, out, err);
|
rp.receive(in, out, err);
|
||||||
@@ -170,15 +171,4 @@ final class Receive extends AbstractGitCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getMaxObjectSizeLimit() {
|
|
||||||
long global = config.getMaxObjectSizeLimit();
|
|
||||||
long local = projectControl.getProjectState().getMaxObjectSizeLimit();
|
|
||||||
if (global > 0 && local > 0) {
|
|
||||||
return Math.min(global, local);
|
|
||||||
} else {
|
|
||||||
// zero means "no limit", in this case the max is more limiting
|
|
||||||
return Math.max(global, local);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user