Merge "Revert "Improve error message when trying to specify code owners by username""
diff --git a/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java b/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
index 0e872a9..32c82a1 100644
--- a/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
+++ b/java/com/google/gerrit/plugins/codeowners/acceptance/AbstractCodeOwnersTest.java
@@ -225,7 +225,7 @@
protected void createNonParseableCodeOwnerConfig(String path) throws Exception {
disableCodeOwnersForProject(project);
String changeId =
- createChange("Add invalid code owners file", JgitPath.of(path).get(), "@INVALID")
+ createChange("Add invalid code owners file", JgitPath.of(path).get(), "INVALID")
.getChangeId();
approve(changeId);
gApi.changes().id(changeId).current().submit();
@@ -240,9 +240,9 @@
return getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: @INVALID",
+ "invalid line: INVALID",
ProtoBackend.class,
- "1:1: Expected identifier. Found '@'"));
+ "1:8: Expected \"{\"."));
}
protected String getParsingErrorMessage(
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 a8562ae..5f35099 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java
@@ -149,10 +149,9 @@
private static final String EOL = "[\\s]*(#.*)?$"; // end-of-line
private static final String GLOB = "[^\\s,=]+"; // a file glob
- private static final String USERNAME_OR_EMAIL_OR_STAR =
- "([^\\s<>@#,]+|[^\\s<>@,]+@[^\\s<>@#,]+|\\*)";
- private static final String USERNAME_OR_EMAIL_LIST =
- "(" + USERNAME_OR_EMAIL_OR_STAR + "(" + COMMA + USERNAME_OR_EMAIL_OR_STAR + ")*)";
+ private static final String EMAIL_OR_STAR = "([^\\s<>@,]+@[^\\s<>@#,]+|\\*)";
+ private static final String EMAIL_LIST =
+ "(" + EMAIL_OR_STAR + "(" + COMMA + EMAIL_OR_STAR + ")*)";
// Optional name of a Gerrit project followed by a colon and optional spaces.
private static final String PROJECT_NAME = "([^\\s:]+" + COLON + ")?";
@@ -173,15 +172,14 @@
// Simple input lines with 0 or 1 sub-pattern.
private static final Pattern PAT_COMMENT = Pattern.compile(BOL + EOL);
- private static final Pattern PAT_EMAIL = Pattern.compile(BOL + USERNAME_OR_EMAIL_OR_STAR + EOL);
+ private static final Pattern PAT_EMAIL = Pattern.compile(BOL + EMAIL_OR_STAR + EOL);
private static final Pattern PAT_ANNOTATION = Pattern.compile("#\\{([A-Za-z_]+)\\}");
private static final Pattern PAT_INCLUDE =
Pattern.compile(BOL + INCLUDE_OR_FILE + PROJECT_BRANCH_AND_FILE + EOL);
private static final Pattern PAT_NO_PARENT = Pattern.compile(BOL + SET_NOPARENT + EOL);
private static final Pattern PAT_PER_FILE_OWNERS =
- Pattern.compile(
- "^(" + USERNAME_OR_EMAIL_LIST + "|" + SET_NOPARENT + "|" + FILE_DIRECTIVE + ")$");
+ Pattern.compile("^(" + EMAIL_LIST + "|" + SET_NOPARENT + "|" + FILE_DIRECTIVE + ")$");
private static final Pattern PAT_PER_FILE_INCLUDE =
Pattern.compile("^(" + INCLUDE_DIRECTIVE + ")$");
private static final Pattern PAT_GLOBS =
diff --git a/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java b/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java
index 1c4d42f..0083497 100644
--- a/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java
+++ b/java/com/google/gerrit/plugins/codeowners/validation/CodeOwnerConfigValidator.java
@@ -959,14 +959,6 @@
Path codeOwnerConfigFilePath,
CodeOwnerReference codeOwnerReference) {
CodeOwnerResolver codeOwnerResolver = codeOwnerResolverProvider.get().forUser(user);
- if (!CodeOwnerResolver.ALL_USERS_WILDCARD.equals(codeOwnerReference.email())
- && !codeOwnerReference.email().contains("@")) {
- return nonResolvableCodeOwner(
- branchNameKey,
- String.format(
- "code owner '%s' in '%s' cannot be resolved (must be an email)",
- codeOwnerReference.email(), codeOwnerConfigFilePath));
- }
if (!codeOwnerResolver.isEmailDomainAllowed(codeOwnerReference.email()).get()) {
return nonResolvableCodeOwner(
branchNameKey,
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesInRevisionIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesInRevisionIT.java
index e061a8d..980ee02 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesInRevisionIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CheckCodeOwnerConfigFilesInRevisionIT.java
@@ -117,7 +117,7 @@
disableCodeOwnersForProject(project);
String changeId =
- createChange("Add code owners", JgitPath.of(codeOwnerConfigPath).get(), "@INVALID")
+ createChange("Add code owners", JgitPath.of(codeOwnerConfigPath).get(), "INVALID")
.getChangeId();
enableCodeOwnersForProject(project);
@@ -133,9 +133,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: @INVALID",
+ "invalid line: INVALID",
ProtoBackend.class,
- "1:1: Expected identifier. Found '@'"))))));
+ "1:8: Expected \"{\"."))))));
}
@Test
@@ -440,7 +440,7 @@
"Add code owners",
ImmutableMap.of(
JgitPath.of(pathOfNonParseableCodeOwnerConfig).get(),
- "@INVALID",
+ "INVALID",
JgitPath.of(pathOfInvalidCodeOwnerConfig).get(),
format(
CodeOwnerConfig.builder(keyOfInvalidCodeOwnerConfig, TEST_REVISION)
@@ -463,9 +463,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: @INVALID",
+ "invalid line: INVALID",
ProtoBackend.class,
- "1:1: Expected identifier. Found '@'"))))));
+ "1:8: Expected \"{\"."))))));
if (verbosity == null
|| ConsistencyProblemInfo.Status.ERROR.equals(verbosity)
|| ConsistencyProblemInfo.Status.WARNING.equals(verbosity)) {
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 59e7b52..51b52da 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/CodeOwnerConfigValidatorIT.java
@@ -91,9 +91,6 @@
public class CodeOwnerConfigValidatorIT extends AbstractCodeOwnersIT {
private static final ObjectId TEST_REVISION =
ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
- private static final String INVALID = "@INVALID";
- private static final String INVALID_2 = "@INVALID2";
- private static final String PROTO_SYNTAX_ERROR = "1:1: Expected identifier. Found '@'";
@Inject private RequestScopeOperations requestScopeOperations;
@Inject private ProjectOperations projectOperations;
@@ -113,7 +110,7 @@
@Test
public void nonCodeOwnerConfigFileIsNotValidated() throws Exception {
- PushOneCommit.Result r = createChange("Add arbitrary file", "arbitrary-file.txt", INVALID);
+ PushOneCommit.Result r = createChange("Add arbitrary file", "arbitrary-file.txt", "INVALID");
assertOkWithoutMessages(r);
}
@@ -123,7 +120,7 @@
createChange(
"Add code owner config with file extension",
getCodeOwnerConfigFileName() + ".foo",
- INVALID);
+ "INVALID");
assertOkWithoutMessages(r);
}
@@ -134,7 +131,7 @@
createChange(
"Add code owner config with file extension",
getCodeOwnerConfigFileName() + ".foo",
- INVALID);
+ "INVALID");
String abbreviatedCommit = abbreviateName(r.getCommit());
r.assertErrorStatus(
String.format(
@@ -151,7 +148,7 @@
createChange(
"Add code owner config with file extension",
getCodeOwnerConfigFileName() + ".foo",
- INVALID);
+ "INVALID");
String abbreviatedCommit = abbreviateName(r.getCommit());
r.assertErrorStatus(
String.format(
@@ -434,7 +431,7 @@
@GerritConfig(name = "plugin.code-owners.backend", value = "non-existing-backend")
public void canUploadNonParseableConfigIfCodeOwnersPluginConfigurationIsInvalid()
throws Exception {
- PushOneCommit.Result r = createChange("Add code owners", "OWNERS", INVALID);
+ PushOneCommit.Result r = createChange("Add code owners", "OWNERS", "INVALID");
assertOkWithWarnings(
r,
"skipping validation of code owner config files",
@@ -451,7 +448,7 @@
codeOwnerConfigOperations
.codeOwnerConfig(createCodeOwnerConfigKey("/"))
.getJGitFilePath(),
- INVALID);
+ "INVALID");
assertOkWithHints(
r,
"skipping validation of code owner config files",
@@ -582,7 +579,7 @@
codeOwnerConfigOperations
.codeOwnerConfig(createCodeOwnerConfigKey("/"))
.getJGitFilePath(),
- INVALID);
+ "INVALID");
push.setPushOptions(ImmutableList.copyOf(pushOptions));
return push.to("refs/for/master");
}
@@ -611,7 +608,7 @@
createChange(
"Add code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID);
+ "INVALID");
assertFatalWithMessages(
r,
"invalid code owner config files",
@@ -622,9 +619,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID,
+ "invalid line: INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))));
+ "1:8: expected \"{\""))));
}
@Test
@@ -636,7 +633,7 @@
createChange(
"Add code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID);
+ "INVALID");
assertOkWithFatals(
r,
"invalid code owner config files",
@@ -647,9 +644,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID,
+ "invalid line: INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))));
+ "1:8: expected \"{\""))));
}
@Test
@@ -667,7 +664,7 @@
createChange(
"Add code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID);
+ "INVALID");
assertOkWithFatals(
r,
"invalid code owner config files",
@@ -678,9 +675,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID,
+ "invalid line: INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))));
+ "1:8: expected \"{\""))));
}
@Test
@@ -755,7 +752,7 @@
String path =
codeOwnerConfigOperations.codeOwnerConfig(createCodeOwnerConfigKey("/")).getJGitFilePath();
- PushOneCommit.Result r = createChange("Add code owners", path, INVALID);
+ PushOneCommit.Result r = createChange("Add code owners", path, "INVALID");
r.assertOkStatus();
// re-enable the code owners functionality for the project
@@ -781,7 +778,7 @@
createChange(
"Add code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID);
+ "INVALID");
r.assertOkStatus();
// re-enable the code owners functionality for the project
@@ -792,7 +789,7 @@
createChange(
"Update code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID_2);
+ "STILL INVALID");
assertOkWithWarnings(
r,
"invalid code owner config files",
@@ -803,9 +800,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID_2,
+ "invalid line: STILL INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))));
+ "1:7: expected \"{\""))));
}
@Test
@@ -821,7 +818,7 @@
createChange(
"Add code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID);
+ "INVALID");
r.assertOkStatus();
// re-enable the code owners functionality for the project
@@ -907,7 +904,7 @@
createChange(
"Add code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID);
+ "INVALID");
assertFatalWithMessages(
r,
"invalid code owner config files",
@@ -918,9 +915,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID,
+ "invalid line: INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))));
+ "1:8: expected \"{\""))));
}
@Test
@@ -942,7 +939,7 @@
createChange(
"Add code owners",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- INVALID);
+ "INVALID");
assertFatalWithMessages(
r,
"invalid code owner config files",
@@ -953,9 +950,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID,
+ "invalid line: INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))));
+ "1:8: expected \"{\""))));
}
@Test
@@ -970,9 +967,9 @@
"Add code owners",
ImmutableMap.of(
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey1).getJGitFilePath(),
- INVALID,
+ "INVALID",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey2).getJGitFilePath(),
- INVALID_2));
+ "ALSO-INVALID"));
PushOneCommit.Result r = push.to("refs/for/master");
assertFatalWithMessages(
r,
@@ -984,9 +981,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID,
+ "invalid line: INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))),
+ "1:8: expected \"{\""))),
String.format(
"invalid code owner config file '%s' (project = %s, branch = master):\n %s",
codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey2).getFilePath(),
@@ -994,9 +991,9 @@
getParsingErrorMessage(
ImmutableMap.of(
FindOwnersBackend.class,
- "invalid line: " + INVALID_2,
+ "invalid line: ALSO-INVALID",
ProtoBackend.class,
- PROTO_SYNTAX_ERROR))));
+ "1:1: expected identifier. found 'ALSO-INVALID'"))));
}
@Test
@@ -1031,101 +1028,6 @@
}
@Test
- public void cannotUploadConfigWithNonResolvablePerFileCodeOwners() throws Exception {
- CodeOwnerConfig.Key codeOwnerConfigKey = createCodeOwnerConfigKey("/");
-
- String unknownEmail1 = "non-existing-email@example.com";
- String unknownEmail2 = "another-unknown-email@example.com";
- PushOneCommit.Result r =
- createChange(
- "Add code owners",
- codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- format(
- CodeOwnerConfig.builder(codeOwnerConfigKey, TEST_REVISION)
- .addCodeOwnerSet(
- CodeOwnerSet.builder()
- .addPathExpression("foo")
- .addCodeOwnerEmail(unknownEmail1)
- .addCodeOwnerEmail(admin.email())
- .addCodeOwnerEmail(unknownEmail2)
- .build())
- .build()));
- assertErrorWithMessages(
- r,
- "invalid code owner config files",
- String.format(
- "code owner email '%s' in '%s' cannot be resolved for %s",
- unknownEmail1,
- codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath(),
- identifiedUserFactory.create(admin.id()).getLoggableName()),
- String.format(
- "code owner email '%s' in '%s' cannot be resolved for %s",
- unknownEmail2,
- codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath(),
- identifiedUserFactory.create(admin.id()).getLoggableName()));
- }
-
- @Test
- public void cannotUploadConfigWithNonEmailCodeOwners() throws Exception {
- CodeOwnerConfig.Key codeOwnerConfigKey = createCodeOwnerConfigKey("/");
-
- String username1 = "user1";
- String username2 = "user2";
- PushOneCommit.Result r =
- createChange(
- "Add code owners",
- codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- format(
- CodeOwnerConfig.builder(codeOwnerConfigKey, TEST_REVISION)
- .addCodeOwnerSet(
- CodeOwnerSet.createWithoutPathExpressions(
- username1, admin.email(), username2))
- .build()));
- assertErrorWithMessages(
- r,
- "invalid code owner config files",
- String.format(
- "code owner '%s' in '%s' cannot be resolved (must be an email)",
- username1, codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath()),
- String.format(
- "code owner '%s' in '%s' cannot be resolved (must be an email)",
- username2,
- codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath()));
- }
-
- @Test
- public void cannotUploadConfigWithNonEmailPerFileCodeOwners() throws Exception {
- CodeOwnerConfig.Key codeOwnerConfigKey = createCodeOwnerConfigKey("/");
-
- String username1 = "user1";
- String username2 = "user2";
- String pathExpression = "foo";
- PushOneCommit.Result r =
- createChange(
- "Add code owners",
- codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getJGitFilePath(),
- format(
- CodeOwnerConfig.builder(codeOwnerConfigKey, TEST_REVISION)
- .addCodeOwnerSet(
- CodeOwnerSet.builder()
- .addPathExpression(pathExpression)
- .addCodeOwnerEmail(username1)
- .addCodeOwnerEmail(username2)
- .build())
- .build()));
- assertErrorWithMessages(
- r,
- "invalid code owner config files",
- String.format(
- "code owner '%s' in '%s' cannot be resolved (must be an email)",
- username1, codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath()),
- String.format(
- "code owner '%s' in '%s' cannot be resolved (must be an email)",
- username2,
- codeOwnerConfigOperations.codeOwnerConfig(codeOwnerConfigKey).getFilePath()));
- }
-
- @Test
@GerritConfig(name = "plugin.code-owners.allowedEmailDomain", value = "example.com")
public void canUploadConfigThatAssignsCodeOwnershipToAnEmailWithAnAllowedEmailDomain()
throws Exception {
@@ -2189,7 +2091,7 @@
codeOwnerConfigOperations
.codeOwnerConfig(keyOfImportedCodeOwnerConfig)
.getJGitFilePath(),
- INVALID);
+ "INVALID");
r.assertOkStatus();
approve(r.getChangeId());
gApi.changes().id(r.getChangeId()).current().submit();
@@ -3189,7 +3091,7 @@
codeOwnerConfigOperations
.codeOwnerConfig(createCodeOwnerConfigKey("/"))
.getJGitFilePath(),
- INVALID);
+ "INVALID");
assertOkWithHints(
r,
"skipping validation of code owner config files",
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/restapi/GetCodeOwnerStatusRestIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/restapi/GetCodeOwnerStatusRestIT.java
index ec5f069..8f4959d 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/restapi/GetCodeOwnerStatusRestIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/restapi/GetCodeOwnerStatusRestIT.java
@@ -70,7 +70,7 @@
codeOwnerConfigOperations.codeOwnerConfig(createCodeOwnerConfigKey("/")).getFilePath();
disableCodeOwnersForProject(project);
String changeId =
- createChange("Add code owners", JgitPath.of(filePath).get(), "@INVALID").getChangeId();
+ createChange("Add code owners", JgitPath.of(filePath).get(), "INVALID").getChangeId();
approve(changeId);
gApi.changes().id(changeId).current().submit();
enableCodeOwnersForProject(project);
@@ -84,7 +84,7 @@
.contains(
String.format(
"* invalid code owner config file '%s' (project = %s, branch = master):\n"
- + " invalid line: @INVALID",
+ + " invalid line: INVALID",
filePath, project.get()));
}
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java
index 743f860..7ec9295 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/AbstractFileBasedCodeOwnerBackendTest.java
@@ -424,7 +424,7 @@
.commit()
.parent(head)
.message("Add invalid test code owner config")
- .add(JgitPath.of(codeOwnerConfigKey.filePath(getFileName())).get(), "@INVALID"));
+ .add(JgitPath.of(codeOwnerConfigKey.filePath(getFileName())).get(), "INVALID"));
}
// Try to update the code owner config.
diff --git a/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java b/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java
index f1bbcdf..260e635 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParserTest.java
@@ -158,29 +158,17 @@
codeOwnerConfigParser.parse(
TEST_REVISION,
CodeOwnerConfig.Key.create(project, "master", "/"),
- getCodeOwnerConfig(EMAIL_1, "@INVALID", "NOT_AN_EMAIL", EMAIL_2)));
+ getCodeOwnerConfig(EMAIL_1, "INVALID", "NOT_AN_EMAIL", EMAIL_2)));
assertThat(exception.getFullMessage(FindOwnersBackend.CODE_OWNER_CONFIG_FILE_NAME))
.isEqualTo(
String.format(
"invalid code owner config file '/OWNERS' (project = %s, branch = master):\n"
- + " invalid line: @INVALID",
+ + " invalid line: INVALID\n"
+ + " invalid line: NOT_AN_EMAIL",
project));
}
@Test
- public void codeOwnerConfigWithNonEmailLines() throws Exception {
- assertParseAndFormat(
- getCodeOwnerConfig(EMAIL_1, "NOT_AN_EMAIL", EMAIL_3),
- codeOwnerConfig ->
- assertThat(codeOwnerConfig)
- .hasCodeOwnerSetsThat()
- .onlyElement()
- .hasCodeOwnersEmailsThat()
- .containsExactly(EMAIL_1, "NOT_AN_EMAIL", EMAIL_3),
- getCodeOwnerConfig(EMAIL_1, "NOT_AN_EMAIL", EMAIL_3));
- }
-
- @Test
public void codeOwnerConfigWithComment() throws Exception {
assertParseAndFormat(
getCodeOwnerConfig(EMAIL_1, EMAIL_2 + " # some comment", EMAIL_3),