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