Merge "setup-guide.md: Update outdated info about bootstrapping mode"
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
index eb84049..ac474cb 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
@@ -452,7 +452,10 @@
CodeOwnerConfigValidationPolicy getCodeOwnerConfigValidationPolicyForCommitReceived(
Project.NameKey project, Config pluginConfig) {
return getCodeOwnerConfigValidationPolicy(
- KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED, project, pluginConfig);
+ KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED,
+ project,
+ pluginConfig,
+ CodeOwnerConfigValidationPolicy.TRUE);
}
/**
@@ -495,7 +498,10 @@
CodeOwnerConfigValidationPolicy getCodeOwnerConfigValidationPolicyForSubmit(
Project.NameKey project, Config pluginConfig) {
return getCodeOwnerConfigValidationPolicy(
- KEY_ENABLE_VALIDATION_ON_SUBMIT, project, pluginConfig);
+ KEY_ENABLE_VALIDATION_ON_SUBMIT,
+ project,
+ pluginConfig,
+ CodeOwnerConfigValidationPolicy.FALSE);
}
/**
@@ -554,7 +560,10 @@
}
private CodeOwnerConfigValidationPolicy getCodeOwnerConfigValidationPolicy(
- String key, Project.NameKey project, Config pluginConfig) {
+ String key,
+ Project.NameKey project,
+ Config pluginConfig,
+ CodeOwnerConfigValidationPolicy defaultValue) {
requireNonNull(key, "key");
requireNonNull(project, "project");
requireNonNull(pluginConfig, "pluginConfig");
@@ -563,8 +572,7 @@
pluginConfig.getString(SECTION_CODE_OWNERS, /* subsection= */ null, key);
if (codeOwnerConfigValidationPolicyString != null) {
try {
- return pluginConfig.getEnum(
- SECTION_CODE_OWNERS, /* subsection= */ null, key, CodeOwnerConfigValidationPolicy.TRUE);
+ return pluginConfig.getEnum(SECTION_CODE_OWNERS, /* subsection= */ null, key, defaultValue);
} catch (IllegalArgumentException e) {
logger.atWarning().withCause(e).log(
"Ignoring invalid value %s for the code owner config validation policy in '%s.config'"
@@ -578,16 +586,13 @@
}
try {
- return pluginConfigFromGerritConfig.getEnum(key, CodeOwnerConfigValidationPolicy.TRUE);
+ return pluginConfigFromGerritConfig.getEnum(key, defaultValue);
} catch (IllegalArgumentException e) {
logger.atWarning().withCause(e).log(
"Ignoring invalid value %s for the code owner config validation policy in gerrit.config"
+ " (parameter plugin.%s.%s). Falling back to default value %s.",
- pluginConfigFromGerritConfig.getString(key),
- pluginName,
- key,
- CodeOwnerConfigValidationPolicy.TRUE);
- return CodeOwnerConfigValidationPolicy.TRUE;
+ pluginConfigFromGerritConfig.getString(key), pluginName, key, defaultValue);
+ return defaultValue;
}
}
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
index 7f0e207..555bfcc 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
@@ -168,6 +168,7 @@
}
@Test
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void canSubmitConfigWithoutIssues() throws Exception {
setAsDefaultCodeOwners(admin);
@@ -534,6 +535,7 @@
@Test
@GerritConfig(name = "plugin.code-owners.enableValidationOnCommitReceived", value = "false")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void onReceiveCommitValidationDisabled() throws Exception {
setAsDefaultCodeOwners(admin);
@@ -964,6 +966,7 @@
}
@Test
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void cannotSubmitConfigWithNewIssues() throws Exception {
setAsDefaultCodeOwners(admin);
@@ -1073,6 +1076,7 @@
@Test
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void cannotSubmitConfigWithCodeOwnersThatAreNotVisibleToThePatchSetUploader()
throws Exception {
setAsDefaultCodeOwners(admin);
@@ -1127,6 +1131,7 @@
@Test
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void canSubmitConfigWithCodeOwnersThatAreNotVisibleToTheSubmitterButVisibleToTheUploader()
throws Exception {
setAsDefaultCodeOwners(admin);
@@ -1738,7 +1743,7 @@
codeOwnerConfigOperations.codeOwnerConfig(keyOfImportedCodeOwnerConfig).getFilePath(),
otherProject.get(),
targetBranchName,
- parent1.name()));
+ projectOperations.project(otherProject).getHead(targetBranchName).getName()));
}
@Test
@@ -1835,7 +1840,7 @@
.codeOwnerConfig(keyOfNonExistingCodeOwnerConfig)
.getFilePath(),
otherProject.get(),
- parent1.name()));
+ projectOperations.project(otherProject).getHead("master").getName()));
}
@Test
@@ -2097,6 +2102,7 @@
@Test
@GerritConfig(name = "plugin.code-owners.rejectNonResolvableCodeOwners", value = "false")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void canUploadAndSubmitConfigWithUnresolvableCodeOwners() throws Exception {
setAsDefaultCodeOwners(admin);
@@ -2129,6 +2135,7 @@
@Test
@GerritConfig(name = "plugin.code-owners.rejectNonResolvableImports", value = "false")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void canUploadAndSubmitConfigWithUnresolvableImports() throws Exception {
setAsDefaultCodeOwners(admin);
@@ -2254,6 +2261,7 @@
@Test
@GerritConfig(name = "plugin.code-owners.backend", value = FailingCodeOwnerBackend.ID)
@GerritConfig(name = "plugin.code-owners.fallbackCodeOwners", value = "PROJECT_OWNERS")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void submitFailsOnInternalError() throws Exception {
try (AutoCloseable registration = registerTestBackend(new FailingCodeOwnerBackend())) {
disableCodeOwnersForProject(project);
@@ -2286,6 +2294,7 @@
}
@Test
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void disableValidationForBranch() throws Exception {
setAsDefaultCodeOwners(admin);
@@ -2323,6 +2332,7 @@
}
@Test
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void disableRejectionOfNonResolvableCodeOwnersForBranch() throws Exception {
setAsDefaultCodeOwners(admin);
@@ -2361,6 +2371,7 @@
}
@Test
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void disableRejectionOfNonResolvableImportsForBranch() throws Exception {
skipTestIfImportsNotSupportedByCodeOwnersBackend();
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java
index 5727b63..9e6fb23 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/PutCodeOwnerProjectConfigIT.java
@@ -494,17 +494,9 @@
codeOwnersPluginConfiguration
.getProjectConfig(project)
.getCodeOwnerConfigValidationPolicyForSubmit("master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
-
- CodeOwnerProjectConfigInput input = new CodeOwnerProjectConfigInput();
- input.enableValidationOnSubmit = CodeOwnerConfigValidationPolicy.FALSE;
- projectCodeOwnersApiFactory.project(project).updateConfig(input);
- assertThat(
- codeOwnersPluginConfiguration
- .getProjectConfig(project)
- .getCodeOwnerConfigValidationPolicyForSubmit("master"))
.isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ CodeOwnerProjectConfigInput input = new CodeOwnerProjectConfigInput();
input.enableValidationOnSubmit = CodeOwnerConfigValidationPolicy.TRUE;
projectCodeOwnersApiFactory.project(project).updateConfig(input);
assertThat(
@@ -512,6 +504,14 @@
.getProjectConfig(project)
.getCodeOwnerConfigValidationPolicyForSubmit("master"))
.isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+
+ input.enableValidationOnSubmit = CodeOwnerConfigValidationPolicy.FALSE;
+ projectCodeOwnersApiFactory.project(project).updateConfig(input);
+ assertThat(
+ codeOwnersPluginConfiguration
+ .getProjectConfig(project)
+ .getCodeOwnerConfigValidationPolicyForSubmit("master"))
+ .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
}
@Test
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigSnapshotTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigSnapshotTest.java
index 81a9022..9cc865d 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigSnapshotTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/CodeOwnersPluginConfigSnapshotTest.java
@@ -1022,32 +1022,32 @@
@Test
public void getCodeOwnerConfigValidationPolicyForSubmitd_notConfigured() throws Exception {
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("non-existing"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
}
@Test
public void getCodeOwnerConfigValidationPolicyForSubmit_configuredOnProjectLevel()
throws Exception {
- configureEnableValidationOnSubmit(project, CodeOwnerConfigValidationPolicy.FALSE);
+ configureEnableValidationOnSubmit(project, CodeOwnerConfigValidationPolicy.TRUE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("non-existing"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
}
@Test
public void getCodeOwnerConfigValidationPolicyForSubmit_configuredOnBranchLevel()
throws Exception {
configureEnableValidationOnSubmitForBranch(
- project, "refs/heads/master", CodeOwnerConfigValidationPolicy.FALSE);
+ project, "refs/heads/master", CodeOwnerConfigValidationPolicy.TRUE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
- assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("refs/heads/master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
- assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("foo"))
.isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+ assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("refs/heads/master"))
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+ assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("foo"))
+ .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
}
@Test
@@ -1065,12 +1065,12 @@
GeneralConfig.SECTION_VALIDATION,
"refs/heads/master",
GeneralConfig.KEY_ENABLE_VALIDATION_ON_SUBMIT,
- CodeOwnerConfigValidationPolicy.FALSE);
+ CodeOwnerConfigValidationPolicy.TRUE);
});
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("refs/heads/master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("foo"))
.isEqualTo(CodeOwnerConfigValidationPolicy.DRY_RUN);
}
@@ -1080,12 +1080,12 @@
getCodeOwnerConfigValidationPolicyForSubmit_inheritedBranchLevelConfigTakesPrecedence()
throws Exception {
configureEnableValidationOnSubmitForBranch(
- allProjects, "refs/heads/master", CodeOwnerConfigValidationPolicy.FALSE);
+ allProjects, "refs/heads/master", CodeOwnerConfigValidationPolicy.TRUE);
configureEnableValidationOnSubmit(project, CodeOwnerConfigValidationPolicy.DRY_RUN);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("refs/heads/master"))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("foo"))
.isEqualTo(CodeOwnerConfigValidationPolicy.DRY_RUN);
}
@@ -1094,7 +1094,7 @@
public void getCodeOwnerConfigValidationPolicyForSubmit_inheritedBranchLevelCanBeOverridden()
throws Exception {
configureEnableValidationOnSubmitForBranch(
- allProjects, "refs/heads/master", CodeOwnerConfigValidationPolicy.FALSE);
+ allProjects, "refs/heads/master", CodeOwnerConfigValidationPolicy.TRUE);
configureEnableValidationOnSubmitForBranch(
project, "refs/heads/master", CodeOwnerConfigValidationPolicy.DRY_RUN);
assertThat(cfgSnapshot().getCodeOwnerConfigValidationPolicyForSubmit("master"))
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java
index 5b5b6e9..be65c1f 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java
@@ -951,39 +951,39 @@
@Test
public void noEnableValidationOnSubmitConfiguration() throws Exception {
assertThat(generalConfig.getCodeOwnerConfigValidationPolicyForSubmit(project, new Config()))
- .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
- }
-
- @Test
- @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "false")
- public void
- enableValidationOnSubmitConfigurationIsRetrievedFromGerritConfigIfNotSpecifiedOnProjectLevel()
- throws Exception {
- assertThat(generalConfig.getCodeOwnerConfigValidationPolicyForSubmit(project, new Config()))
.isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
}
@Test
- @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "false")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
+ public void
+ enableValidationOnSubmitConfigurationIsRetrievedFromGerritConfigIfNotSpecifiedOnProjectLevel()
+ throws Exception {
+ assertThat(generalConfig.getCodeOwnerConfigValidationPolicyForSubmit(project, new Config()))
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+ }
+
+ @Test
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void
enableValidationOnSubmitConfigurationInPluginConfigOverridesEnableValidationOnSubmitConfigurationInGerritConfig()
throws Exception {
Config cfg = new Config();
cfg.setString(
- SECTION_CODE_OWNERS, /* subsection= */ null, KEY_ENABLE_VALIDATION_ON_SUBMIT, "true");
+ SECTION_CODE_OWNERS, /* subsection= */ null, KEY_ENABLE_VALIDATION_ON_SUBMIT, "false");
assertThat(generalConfig.getCodeOwnerConfigValidationPolicyForSubmit(project, cfg))
- .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
}
@Test
- @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "false")
+ @GerritConfig(name = "plugin.code-owners.enableValidationOnSubmit", value = "true")
public void invalidEnableValidationOnSubmitConfigurationInPluginConfigIsIgnored()
throws Exception {
Config cfg = new Config();
cfg.setString(
SECTION_CODE_OWNERS, /* subsection= */ null, KEY_ENABLE_VALIDATION_ON_SUBMIT, "INVALID");
assertThat(generalConfig.getCodeOwnerConfigValidationPolicyForSubmit(project, cfg))
- .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
}
@Test
@@ -991,7 +991,7 @@
public void invalidEnableValidationOnSubmitConfigurationInGerritConfigIsIgnored()
throws Exception {
assertThat(generalConfig.getCodeOwnerConfigValidationPolicyForSubmit(project, new Config()))
- .isEqualTo(CodeOwnerConfigValidationPolicy.TRUE);
+ .isEqualTo(CodeOwnerConfigValidationPolicy.FALSE);
}
@Test
diff --git a/resources/Documentation/config.md b/resources/Documentation/config.md
index 62350f2..6250677 100644
--- a/resources/Documentation/config.md
+++ b/resources/Documentation/config.md
@@ -263,7 +263,7 @@
Can be overridden per project by setting
[codeOwners.enableValidationOnSubmit](#codeOwnersEnableValidationOnSubmit)
in `@PLUGIN@.config`.\
- By default `true`.
+ By default `false`.
<a id="pluginCodeOwnersRejectNonResolvableCodeOwners">plugin.@PLUGIN@.rejectNonResolvableCodeOwners</a>
: Whether modifications of code owner config files that newly add
diff --git a/resources/Documentation/validation.md b/resources/Documentation/validation.md
index 182f674..1e4687b 100644
--- a/resources/Documentation/validation.md
+++ b/resources/Documentation/validation.md
@@ -82,11 +82,14 @@
* the file was non-parseable and with the update it is still non-parseable
For [code owner config files](user-guide.html#codeOwnerConfigFiles) the
-validation is also performed on submit (in addition to the validation that is
-performed on upload of the change). This is because relevant configuration can
-change between the time a change is uploaded and the time a change is submitted.
-On submit we repeat the exact same validation that was done on upload. This
-means, all visibility checks will be done from the perspective of the uploader.
+validation may also be performed on submit (in addition to the validation that
+is performed on upload of the change, see
+[enableValidationOnSubmit](config.html#codeOwnersEnableValidationOnSubmit)
+config setting). Repeating the validation on submit can make sense because
+relevant configuration can change between the time a change is uploaded and the
+time a change is submitted. If enabled, on submit we repeat the exact same
+validation that was done on upload. This means, all visibility checks will be
+done from the perspective of the uploader.
### <a id="codeOwnerConfigFileChecks">Validation checks for code owner config files