Merge changes Iffd1de5d,I1992e555
* changes:
GeneralConfig: Include parameter name into warning
Fix removal of inherited global code owners
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 251504a..3558582 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfig.java
@@ -436,8 +436,12 @@
} catch (IllegalArgumentException e) {
logger.atWarning().withCause(e).log(
"Ignoring invalid value %s for the code owner config validation policy in '%s.config'"
- + " of project %s. Falling back to global config.",
- codeOwnerConfigValidationPolicyString, pluginName, project.get());
+ + " of project %s (parameter %s.%s). Falling back to global config.",
+ codeOwnerConfigValidationPolicyString,
+ pluginName,
+ project.get(),
+ SECTION_CODE_OWNERS,
+ key);
}
}
@@ -563,11 +567,13 @@
return Arrays.stream(
pluginConfig.getStringList(
SECTION_CODE_OWNERS, /* subsection= */ null, KEY_GLOBAL_CODE_OWNER))
+ .filter(value -> !value.trim().isEmpty())
.map(CodeOwnerReference::create)
.collect(toImmutableSet());
}
return Arrays.stream(pluginConfigFromGerritConfig.getStringList(KEY_GLOBAL_CODE_OWNER))
+ .filter(value -> !value.trim().isEmpty())
.map(CodeOwnerReference::create)
.collect(toImmutableSet());
}
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 ed66d23..456deb5 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/config/GeneralConfigTest.java
@@ -714,6 +714,16 @@
}
@Test
+ @GerritConfig(
+ name = "plugin.code-owners.globalCodeOwner",
+ values = {"bot1@example.com", "bot2@example.com"})
+ public void inheritedGlobalOwnersCanBeRemovedOnProjectLevel() throws Exception {
+ Config cfg = new Config();
+ cfg.setString(SECTION_CODE_OWNERS, /* subsection= */ null, KEY_GLOBAL_CODE_OWNER, "");
+ assertThat(generalConfig.getGlobalCodeOwners(cfg)).isEmpty();
+ }
+
+ @Test
public void cannotGetExemptedUsersForNullPluginConfig() throws Exception {
NullPointerException npe =
assertThrows(