Remove multiple implementations of getSshHost() in email classes
The getSshHost() method was implemented in both ReplacePatchSetSender and NewChangeSender. Remove these and implement it in the NotificationEmail base class instead. Change-Id: I55e36021915d147e01c676e7837557f5283812f6
This commit is contained in:
committed by
David Pursehouse
parent
618f878dc0
commit
3a495e6c46
@@ -17,9 +17,6 @@ package com.google.gerrit.server.mail;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
|
||||
import com.jcraft.jsch.HostKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -29,14 +26,12 @@ import java.util.Set;
|
||||
|
||||
/** Sends an email alerting a user to a new change for them to review. */
|
||||
public abstract class NewChangeSender extends ChangeEmail {
|
||||
private final SshInfo sshInfo;
|
||||
private final Set<Account.Id> reviewers = new HashSet<Account.Id>();
|
||||
private final Set<Account.Id> extraCC = new HashSet<Account.Id>();
|
||||
|
||||
protected NewChangeSender(EmailArguments ea, String anonymousCowardName,
|
||||
SshInfo sshInfo, Change c) {
|
||||
Change c) {
|
||||
super(ea, anonymousCowardName, c, "newchange");
|
||||
this.sshInfo = sshInfo;
|
||||
}
|
||||
|
||||
public void addReviewers(final Collection<Account.Id> cc) {
|
||||
@@ -73,17 +68,4 @@ public abstract class NewChangeSender extends ChangeEmail {
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public String getSshHost() {
|
||||
final List<HostKey> hostKeys = sshInfo.getHostKeys();
|
||||
if (hostKeys.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String host = hostKeys.get(0).getHost();
|
||||
if (host.startsWith("*:")) {
|
||||
return getGerritHost() + host.substring(1);
|
||||
}
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user