Merge "Upgrade PostgreSQL JDBC driver" into stable-2.14
diff --git a/Documentation/config-project-config.txt b/Documentation/config-project-config.txt
index 649bbf8..faee4e6 100644
--- a/Documentation/config-project-config.txt
+++ b/Documentation/config-project-config.txt
@@ -140,9 +140,12 @@
`gerrit.config` globally (link:config-gerrit.html#receive.maxObjectSizeLimit[
receive.maxObjectSizeLimit]).
+
-The project specific setting in `project.config` is only honored when it
-further reduces the global limit. The setting is not inherited from the
-parent project; it must be explicitly set per project.
+The project specific setting in `project.config` may not set a value higher
+than the global limit (if configured). In other words, it is only honored when
+it further reduces the global limit.
++
+The setting is not inherited from the parent project; it must be explicitly
+set per project.
+
Default is zero.
+
diff --git a/Documentation/rest-api-projects.txt b/Documentation/rest-api-projects.txt
index af3c757..6e460d6 100644
--- a/Documentation/rest-api-projects.txt
+++ b/Documentation/rest-api-projects.txt
@@ -2813,7 +2813,8 @@
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. +
+The max object size limit that is inherited from the global config as a
+formatted string. +
Not set if there is no global limit for the object size.
|===============================
diff --git a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/EventRecorder.java b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/EventRecorder.java
index f25ca83..7348c89 100644
--- a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/EventRecorder.java
+++ b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/EventRecorder.java
@@ -138,6 +138,10 @@
return events;
}
+ public void assertNoRefUpdatedEvents(String project, String branch) throws Exception {
+ getRefUpdatedEvents(project, branch, 0);
+ }
+
public void assertRefUpdatedEvents(String project, String branch, String... expected)
throws Exception {
ImmutableList<RefUpdatedEvent> events =
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java
index e30e9b3..272e2c5 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/project/ProjectIT.java
@@ -18,6 +18,7 @@
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import com.google.gerrit.acceptance.AbstractDaemonTest;
+import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.extensions.api.projects.BranchInput;
@@ -28,6 +29,7 @@
import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
+import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Test;
@@ -41,9 +43,9 @@
assertThat(name).isEqualTo(gApi.projects().create(name).get().name);
RevCommit head = getRemoteHead(name, RefNames.REFS_CONFIG);
- eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
- eventRecorder.assertRefUpdatedEvents(name, "refs/heads/master", new String[] {});
+ eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
+ eventRecorder.assertNoRefUpdatedEvents(name, "refs/heads/master");
}
@Test
@@ -52,9 +54,9 @@
assertThat(name).isEqualTo(gApi.projects().create(name + ".git").get().name);
RevCommit head = getRemoteHead(name, RefNames.REFS_CONFIG);
- eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
- eventRecorder.assertRefUpdatedEvents(name, "refs/heads/master", new String[] {});
+ eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
+ eventRecorder.assertNoRefUpdatedEvents(name, "refs/heads/master");
}
@Test
@@ -120,20 +122,118 @@
}
@Test
- public void config() throws Exception {
+ public void submitType() throws Exception {
RevCommit initialHead = getRemoteHead(project, RefNames.REFS_CONFIG);
- ConfigInfo info = gApi.projects().name(project.get()).config();
+ ConfigInfo info = getConfig();
assertThat(info.submitType).isEqualTo(SubmitType.MERGE_IF_NECESSARY);
ConfigInput input = new ConfigInput();
input.submitType = SubmitType.CHERRY_PICK;
- info = gApi.projects().name(project.get()).config(input);
+ info = setConfig(input);
assertThat(info.submitType).isEqualTo(SubmitType.CHERRY_PICK);
- info = gApi.projects().name(project.get()).config();
+ info = getConfig();
assertThat(info.submitType).isEqualTo(SubmitType.CHERRY_PICK);
RevCommit updatedHead = getRemoteHead(project, RefNames.REFS_CONFIG);
eventRecorder.assertRefUpdatedEvents(
project.get(), RefNames.REFS_CONFIG, initialHead, updatedHead);
}
+
+ @Test
+ public void maxObjectSizeIsNotSetByDefault() throws Exception {
+ ConfigInfo info = getConfig();
+ assertThat(info.maxObjectSizeLimit.value).isNull();
+ assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
+ }
+
+ @Test
+ public void maxObjectSizeCanBeSetAndCleared() throws Exception {
+ // Set a value
+ ConfigInput input = new ConfigInput();
+ input.maxObjectSizeLimit = "100k";
+ ConfigInfo info = setConfig(input);
+ assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k");
+ assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
+
+ // Clear the value
+ input.maxObjectSizeLimit = "0";
+ info = setConfig(input);
+ assertThat(info.maxObjectSizeLimit.value).isNull();
+ assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
+ }
+
+ @Test
+ public void maxObjectSizeIsNotInheritedFromParentProject() throws Exception {
+ Project.NameKey child = createProject(name("child"), project);
+
+ ConfigInput input = new ConfigInput();
+ input.maxObjectSizeLimit = "100k";
+ ConfigInfo info = setConfig(input);
+ assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
+
+ info = getConfig(child);
+ assertThat(info.maxObjectSizeLimit.value).isNull();
+ assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
+ }
+
+ @Test
+ @GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
+ public void maxObjectSizeIsInheritedFromGlobalConfig() throws Exception {
+ ConfigInfo info = getConfig();
+ assertThat(info.maxObjectSizeLimit.value).isEqualTo("200k");
+ assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
+ }
+
+ @Test
+ @GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
+ public void maxObjectSizeOverridesGlobalConfigWhenLower() throws Exception {
+ ConfigInput input = new ConfigInput();
+ input.maxObjectSizeLimit = "100k";
+ ConfigInfo info = setConfig(input);
+ assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k");
+ assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
+ }
+
+ @Test
+ @GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
+ public void maxObjectSizeDoesNotOverrideGlobalConfigWhenHigher() throws Exception {
+ ConfigInput input = new ConfigInput();
+ input.maxObjectSizeLimit = "300k";
+ ConfigInfo info = setConfig(input);
+ assertThat(info.maxObjectSizeLimit.value).isEqualTo("200k");
+ assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("300k");
+ assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
+ }
+
+ @Test
+ public void invalidMaxObjectSizeIsRejected() throws Exception {
+ ConfigInput input = new ConfigInput();
+ input.maxObjectSizeLimit = "100 foo";
+ exception.expect(ResourceConflictException.class);
+ exception.expectMessage("100 foo");
+ setConfig(input);
+ }
+
+ private ConfigInfo setConfig(Project.NameKey name, ConfigInput input) throws Exception {
+ return gApi.projects().name(name.get()).config(input);
+ }
+
+ private ConfigInfo setConfig(ConfigInput input) throws Exception {
+ return setConfig(project, input);
+ }
+
+ private ConfigInfo getConfig(Project.NameKey name) throws Exception {
+ return gApi.projects().name(name.get()).config();
+ }
+
+ private ConfigInfo getConfig() throws Exception {
+ return getConfig(project);
+ }
}
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java
index b09fc0b..144a152 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectInfoScreen.java
@@ -474,6 +474,9 @@
textBox.setValue(param.value());
addWidget(g, textBox, param);
}
+ if (textBox.getValue().length() > textBox.getVisibleLength()) {
+ textBox.setVisibleLength(textBox.getValue().length());
+ }
saveEnabler.listenTo(textBox);
return textBox;
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java
index 2f02728..b80442b 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ConfigInfoImpl.java
@@ -41,7 +41,7 @@
public ConfigInfoImpl(
boolean serverEnableSignedPush,
ProjectControl control,
- TransferConfig config,
+ TransferConfig transferConfig,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
PluginConfigFactory cfgFactory,
AllProjectsName allProjects,
@@ -98,14 +98,7 @@
this.requireSignedPush = requireSignedPush;
}
- MaxObjectSizeLimitInfo maxObjectSizeLimit = new MaxObjectSizeLimitInfo();
- maxObjectSizeLimit.value =
- config.getEffectiveMaxObjectSizeLimit(projectState) == config.getMaxObjectSizeLimit()
- ? config.getFormattedMaxObjectSizeLimit()
- : p.getMaxObjectSizeLimit();
- maxObjectSizeLimit.configuredValue = p.getMaxObjectSizeLimit();
- maxObjectSizeLimit.inheritedValue = config.getFormattedMaxObjectSizeLimit();
- this.maxObjectSizeLimit = maxObjectSizeLimit;
+ this.maxObjectSizeLimit = getMaxObjectSizeLimit(projectState, transferConfig, p);
this.submitType = p.getSubmitType();
this.state =
@@ -129,6 +122,19 @@
this.theme = projectState.getTheme();
}
+ private MaxObjectSizeLimitInfo getMaxObjectSizeLimit(
+ ProjectState projectState, TransferConfig transferConfig, Project p) {
+ MaxObjectSizeLimitInfo info = new MaxObjectSizeLimitInfo();
+ info.value =
+ transferConfig.getEffectiveMaxObjectSizeLimit(projectState)
+ == transferConfig.getMaxObjectSizeLimit()
+ ? transferConfig.getFormattedMaxObjectSizeLimit()
+ : p.getMaxObjectSizeLimit();
+ info.configuredValue = p.getMaxObjectSizeLimit();
+ info.inheritedValue = transferConfig.getFormattedMaxObjectSizeLimit();
+ return info;
+ }
+
private Map<String, Map<String, ConfigParameterInfo>> getPluginConfig(
ProjectState project,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/GetConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/GetConfig.java
index 8192e29..08df386 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/project/GetConfig.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/GetConfig.java
@@ -29,7 +29,7 @@
@Singleton
public class GetConfig implements RestReadView<ProjectResource> {
private final boolean serverEnableSignedPush;
- private final TransferConfig config;
+ private final TransferConfig transferConfig;
private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
private final PluginConfigFactory cfgFactory;
private final AllProjectsName allProjects;
@@ -38,13 +38,13 @@
@Inject
public GetConfig(
@EnableSignedPush boolean serverEnableSignedPush,
- TransferConfig config,
+ TransferConfig transferConfig,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
PluginConfigFactory cfgFactory,
AllProjectsName allProjects,
DynamicMap<RestView<ProjectResource>> views) {
this.serverEnableSignedPush = serverEnableSignedPush;
- this.config = config;
+ this.transferConfig = transferConfig;
this.pluginConfigEntries = pluginConfigEntries;
this.allProjects = allProjects;
this.cfgFactory = cfgFactory;
@@ -56,7 +56,7 @@
return new ConfigInfoImpl(
serverEnableSignedPush,
resource.getControl(),
- config,
+ transferConfig,
pluginConfigEntries,
cfgFactory,
allProjects,
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/PutConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/PutConfig.java
index a7e6d10..4ec8a77 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/project/PutConfig.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/PutConfig.java
@@ -58,7 +58,7 @@
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
private final ProjectCache projectCache;
private final ProjectState.Factory projectStateFactory;
- private final TransferConfig config;
+ private final TransferConfig transferConfig;
private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
private final PluginConfigFactory cfgFactory;
private final AllProjectsName allProjects;
@@ -71,7 +71,7 @@
Provider<MetaDataUpdate.User> metaDataUpdateFactory,
ProjectCache projectCache,
ProjectState.Factory projectStateFactory,
- TransferConfig config,
+ TransferConfig transferConfig,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
PluginConfigFactory cfgFactory,
AllProjectsName allProjects,
@@ -81,7 +81,7 @@
this.metaDataUpdateFactory = metaDataUpdateFactory;
this.projectCache = projectCache;
this.projectStateFactory = projectStateFactory;
- this.config = config;
+ this.transferConfig = transferConfig;
this.pluginConfigEntries = pluginConfigEntries;
this.cfgFactory = cfgFactory;
this.allProjects = allProjects;
@@ -172,11 +172,11 @@
throw new ResourceConflictException("Cannot update " + projectName, e);
}
- ProjectState state = projectStateFactory.create(projectConfig);
+ ProjectState state = projectStateFactory.create(ProjectConfig.read(md));
return new ConfigInfoImpl(
serverEnableSignedPush,
state.controlFor(user.get()),
- config,
+ transferConfig,
pluginConfigEntries,
cfgFactory,
allProjects,