Implemented ssh command create-group

Often, when creating a new gerrit project a gerrit admin
needs to create a new project owner group and setup an initial
set of group members. This was only possible from gerrit's Web UI
and was a realtively slow process compared to the easiness of
creating the project using the create-project ssh command.

This command makes it possible to create a new group, assign
group members, owner group and description via ssh.

Bug: issue 313
Change-Id: I9fbc013bd5e596f0b23e411ee0cc72d5f67b5f39
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
This commit is contained in:
Sasa Zivkov
2010-07-30 15:13:58 +02:00
parent 086b7196e7
commit 71963a5e0e
7 changed files with 216 additions and 7 deletions

View File

@@ -46,8 +46,8 @@ public class AccountResolver {
*
* @param nameOrEmail a string of the format
* "Full Name &lt;email@example&gt;", just the email address
* ("email@example"), a full name ("Full Name"), or an account id
* ("18419").
* ("email@example"), a full name ("Full Name"), an account id
* ("18419") or an user name ("username").
* @return the single account that matches; null if no account matches or
* there are multiple candidates.
*/
@@ -61,7 +61,16 @@ public class AccountResolver {
return byId.get(Account.Id.parse(nameOrEmail)).getAccount();
}
return findByNameOrEmail(nameOrEmail);
Account account = findByNameOrEmail(nameOrEmail);
if (account != null) {
return account;
}
if (nameOrEmail.matches(Account.USER_NAME_PATTERN)) {
return findByUserName(nameOrEmail);
}
return null;
}
/**
@@ -105,4 +114,9 @@ public class AccountResolver {
final List<Account> r = rs.toList();
return r.size() == 1 ? r.get(0) : null;
}
private Account findByUserName(final String userName) throws OrmException {
AccountState as = byId.getByUsername(userName);
return as != null ? as.getAccount() : null;
}
}