Merge changes Iae0db563,I7e6695e0,I2a2eb65d
* changes:
Test different formats for paths to import code owner configs
FindOwnersCodeOwnerConfigParser: Remove limitation from class javadoc
GeneralConfig: Fix error message for invalid fallback code owners
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java b/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
index 561c3b1..7a4261a 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
@@ -50,14 +50,6 @@
* <p>The syntax is described at in the {@code find-owners} plugin documentation at:
* https://gerrit.googlesource.com/plugins/find-owners/+/master/src/main/resources/Documentation/syntax.md
*
- * <p><strong>Note:</strong> Currently this class only supports a subset of the syntax. Only the
- * following syntax elements are supported:
- *
- * <ul>
- * <li>comment: a line can be a comment (comments must start with '#')
- * <li>code owner emails: a line can be the email of a code owner
- * </ul>
- *
* <p>Comment lines are silently ignored.
*
* <p>Invalid lines cause the parsing to fail and trigger a {@link CodeOwnerConfigParseException}.
diff --git a/java/com/google/gerrit/plugins/codeowners/config/GeneralConfig.java b/java/com/google/gerrit/plugins/codeowners/config/GeneralConfig.java
index 54ddf7c..8a15dcb 100644
--- a/java/com/google/gerrit/plugins/codeowners/config/GeneralConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/config/GeneralConfig.java
@@ -227,7 +227,7 @@
+ " plugin.%s.%s). Falling back to default value %s.",
pluginConfigFromGerritConfig.getString(KEY_FALLBACK_CODE_OWNERS),
pluginName,
- KEY_ENABLE_VALIDATION_ON_COMMIT_RECEIVED,
+ KEY_FALLBACK_CODE_OWNERS,
FallbackCodeOwners.NONE);
return FallbackCodeOwners.NONE;
}
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java
index 747bd83..42d3696 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigReferenceTest.java
@@ -14,10 +14,15 @@
package com.google.gerrit.plugins.codeowners.backend;
+import static com.google.common.truth.PathSubject.paths;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import com.google.gerrit.plugins.codeowners.acceptance.AbstractCodeOwnersTest;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Optional;
import org.junit.Test;
@@ -45,4 +50,23 @@
.build());
assertThat(exception).hasMessageThat().isEqualTo("branch must be full name: master");
}
+
+ @Test
+ public void absoluteFilePathCanBeSpecifiedInDifferentFormats() throws Exception {
+ Path expectedPath = Paths.get("/foo/OWNERS");
+ for (String inputPath : new String[] {"/foo/OWNERS", "//foo/OWNERS"}) {
+ Path path =
+ CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, inputPath).filePath();
+ assertWithMessage(inputPath).about(paths()).that(path).isEqualTo(expectedPath);
+ assertThat(path.isAbsolute()).isTrue();
+ }
+ }
+
+ @Test
+ public void relativeFilePathCanBeSpecified() throws Exception {
+ Path path =
+ CodeOwnerConfigReference.create(CodeOwnerConfigImportMode.ALL, "foo/OWNERS").filePath();
+ assertThat(path).isEqualTo(Paths.get("foo/OWNERS"));
+ assertThat(path.isAbsolute()).isFalse();
+ }
}