Refactor complex logic out of formatters into getters.
Create 2 new getters via refactoring: getSshHost() and getEmailRegistrationToken() and use them in formatters. Change-Id: I7f9bc24521b38222c80ed3f57fcbf8de032a6203
This commit is contained in:
@@ -125,24 +125,31 @@ public class ReplacePatchSetSender extends ReplyToChangeSender {
|
||||
}
|
||||
|
||||
private String getPullUrl() {
|
||||
final List<HostKey> hostKeys = sshInfo.getHostKeys();
|
||||
if (hostKeys.isEmpty()) {
|
||||
final String host = getSshHost();
|
||||
if (host == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
final String host = hostKeys.get(0).getHost();
|
||||
final StringBuilder r = new StringBuilder();
|
||||
r.append("git pull ssh://");
|
||||
if (host.startsWith("*:")) {
|
||||
r.append(getGerritHost());
|
||||
r.append(host.substring(1));
|
||||
} else {
|
||||
r.append(host);
|
||||
}
|
||||
r.append(host);
|
||||
r.append("/");
|
||||
r.append(projectName);
|
||||
r.append(" ");
|
||||
r.append(patchSet.getRefName());
|
||||
return r.toString();
|
||||
}
|
||||
|
||||
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