Fix for issue 2016 ssh keys not flushed
ssh keys that are added and deleted via the command line command
set-account username --add-ssh-key don't take effect until after
the caches have been flushed manually. This is cause by the fact
that account.getUserName returns null.
Change-Id: I23e66d5734f21bb5e378cfb99d4507379fc9334b
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetAccountCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetAccountCommand.java
index a3e9d6e..c938891 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetAccountCommand.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetAccountCommand.java
@@ -136,6 +136,13 @@
boolean accountUpdated = false;
boolean sshKeysUpdated = false;
+ ResultSet<AccountExternalId> ids = db.accountExternalIds().byAccount(id);
+ for (AccountExternalId extId : ids) {
+ if (extId.isScheme(AccountExternalId.SCHEME_USERNAME)) {
+ account.setUserName(extId.getSchemeRest());
+ }
+ }
+
for (String email : addEmails) {
link(id, email);
}