Use Account.find to handle Receive's --to/--cc user lookup

This way we can specify users by name, e.g.:

  git push --receive-pack="gerrit-receive-pack --to='Shawn Pearce'"

The single quoting is necessary to escape the space and ensure the
name is retained as a single value to --to.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2008-12-31 08:50:29 -08:00
parent 56d76c11a7
commit 7f00fd9b34

View File

@@ -209,16 +209,12 @@ class Receive extends AbstractGitCommand {
final StringBuilder errors = new StringBuilder();
try {
for (final String email : emails) {
final List<Account> who =
db.accounts().byPreferredEmail(email).toList();
if (who.size() == 1) {
accountIds.add(who.get(0).getId());
} else if (who.size() == 0) {
errors.append("fatal: " + addressType + " " + email
+ " is not registered on Gerrit\n");
final Account who = Account.find(db, email);
if (who != null) {
accountIds.add(who.getId());
} else {
errors.append("fatal: " + addressType + " " + email
+ " matches more than one account on Gerrit\n");
+ " is not registered on Gerrit\n");
}
}
} catch (OrmException err) {