Merge "Fix resolving accounts from commit footers to use exact matching"

This commit is contained in:
Youssef Elghareeb
2020-08-18 14:49:26 +00:00
committed by Gerrit Code Review
3 changed files with 52 additions and 1 deletions

View File

@@ -567,6 +567,25 @@ public class AccountResolver {
input, nameOrEmailSearchers, visibilitySupplierCanSee(), accountActivityPredicate());
}
/**
* Same as {@link #resolveByNameOrEmail(String)}, but with exact matching for the full name, email
* and full name.
*
* @param input input string.
* @return a result describing matching accounts. Never null even if the result set is empty.
* @throws ConfigInvalidException if an error occurs.
* @throws IOException if an error occurs.
* @deprecated for use only by MailUtil for parsing commit footers; that class needs to be
* reevaluated.
*/
public Result resolveByExactNameOrEmail(String input) throws ConfigInvalidException, IOException {
return searchImpl(
input,
ImmutableList.of(new ByNameAndEmail(), new ByEmail(), new ByFullName(), new ByUsername()),
visibilitySupplierCanSee(),
accountActivityPredicate());
}
private Supplier<Predicate<AccountState>> visibilitySupplierCanSee() {
return () -> accountControlFactory.get()::canSee;
}

View File

@@ -72,7 +72,7 @@ public class MailUtil {
@SuppressWarnings("deprecation")
private static Account.Id toAccountId(AccountResolver accountResolver, String nameOrEmail)
throws UnprocessableEntityException, IOException, ConfigInvalidException {
return accountResolver.resolveByNameOrEmail(nameOrEmail).asUnique().account().id();
return accountResolver.resolveByExactNameOrEmail(nameOrEmail).asUnique().account().id();
}
private static boolean isReviewer(FooterLine candidateFooterLine) {