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:
Martin Fick
2010-07-20 18:47:14 -06:00
parent df89f998d5
commit dc8df3553d
3 changed files with 44 additions and 26 deletions

View File

@@ -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;
}
}