Convert 3 email classes to file based templates.
Convert the NewChange, RegisterNewEmail and ReplacePatchSet classes to use file based velocity templates which an admin may edit. Factor out getChangeDetail and getReviewersNames from formatChangeDetail and formatSalutation respectively to enable this. Change-Id: I36aa7051f06c7641114e2e681639267769846c22
This commit is contained in:
@@ -20,6 +20,7 @@ import com.google.gerrit.server.ssh.SshInfo;
|
||||
|
||||
import com.jcraft.jsch.HostKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -58,73 +59,18 @@ public abstract class NewChangeSender extends ChangeEmail {
|
||||
|
||||
@Override
|
||||
protected void formatChange() throws EmailException {
|
||||
formatSalutation();
|
||||
formatChangeDetail();
|
||||
|
||||
appendText("\n");
|
||||
appendText(" " + getPullUrl() + "\n");
|
||||
appendText(velocifyFile("NewChange.vm"));
|
||||
}
|
||||
|
||||
private void formatSalutation() {
|
||||
final String changeUrl = getChangeUrl();
|
||||
|
||||
public List<String> getReviewerNames() {
|
||||
if (reviewers.isEmpty()) {
|
||||
formatDest();
|
||||
if (changeUrl != null) {
|
||||
appendText("\n");
|
||||
appendText(" " + changeUrl + "\n");
|
||||
appendText("\n");
|
||||
}
|
||||
appendText("\n");
|
||||
|
||||
} else {
|
||||
appendText("Hello");
|
||||
for (final Iterator<Account.Id> i = reviewers.iterator(); i.hasNext();) {
|
||||
appendText(" ");
|
||||
appendText(getNameFor(i.next()));
|
||||
appendText(",");
|
||||
}
|
||||
appendText("\n");
|
||||
appendText("\n");
|
||||
|
||||
appendText("I'd like you to do a code review.");
|
||||
if (changeUrl != null) {
|
||||
appendText(" Please visit\n");
|
||||
appendText("\n");
|
||||
appendText(" " + changeUrl + "\n");
|
||||
appendText("\n");
|
||||
appendText("to review the following change:\n");
|
||||
}
|
||||
appendText("\n");
|
||||
|
||||
formatDest();
|
||||
appendText("\n");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void formatDest() {
|
||||
appendText("Change " + change.getKey().abbreviate());
|
||||
appendText(" for ");
|
||||
appendText(change.getDest().getShortName());
|
||||
appendText(" in ");
|
||||
appendText(projectName);
|
||||
appendText(":\n");
|
||||
}
|
||||
|
||||
private String getPullUrl() {
|
||||
final String host = getSshHost();
|
||||
if (host == null) {
|
||||
return "";
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (Account.Id id : reviewers) {
|
||||
names.add(getNameFor(id));
|
||||
}
|
||||
|
||||
final StringBuilder r = new StringBuilder();
|
||||
r.append("git pull ssh://");
|
||||
r.append(host);
|
||||
r.append("/");
|
||||
r.append(projectName);
|
||||
r.append(" ");
|
||||
r.append(patchSet.getRefName());
|
||||
return r.toString();
|
||||
return names;
|
||||
}
|
||||
|
||||
public String getSshHost() {
|
||||
|
||||
Reference in New Issue
Block a user