Use a template to set the footer on ChangeEmails.
Add an admin editable ChangeFooter.vm template used to format the footer in ChangeEmails. Change-Id: I8f6f80b7a3e1fdb39ee1ea20aa84738286bce826
This commit is contained in:
parent
7305be4faf
commit
82bd12c409
|
@ -25,6 +25,12 @@ are listed below. Change emails are influenced by two additional templates,
|
|||
one to set the subject line, and one to set the footer which gets appended to
|
||||
all the change emails (see `ChangeSubject.vm` and `ChangeFooter.vm` below.)
|
||||
|
||||
ChangeFooter.vm
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
The `ChangeFooter.vm` template will determine the contents of the footer
|
||||
text that will be appended to emails related to changes (all `ChangeEmails)`.
|
||||
|
||||
ChangeSubject.vm
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public class SitePathInitializer {
|
|||
extract(site.gerrit_sh, Init.class, "gerrit.sh");
|
||||
chmod(0755, site.gerrit_sh);
|
||||
|
||||
extractMailExample("ChangeFooter.vm");
|
||||
extractMailExample("ChangeSubject.vm");
|
||||
extractMailExample("Merged.vm");
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||
|
||||
private ProjectState projectState;
|
||||
protected ChangeData changeData;
|
||||
private boolean inFooter;
|
||||
|
||||
protected ChangeEmail(EmailArguments ea, final Change c, final String mc) {
|
||||
super(ea, mc);
|
||||
|
@ -76,29 +75,7 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||
/** Format the message body by calling {@link #appendText(String)}. */
|
||||
protected void format() throws EmailException {
|
||||
formatChange();
|
||||
if (getChangeUrl() != null) {
|
||||
openFooter();
|
||||
appendText("To view visit ");
|
||||
appendText(getChangeUrl());
|
||||
appendText("\n");
|
||||
}
|
||||
if (getSettingsUrl() != null) {
|
||||
openFooter();
|
||||
appendText("To unsubscribe, visit ");
|
||||
appendText(getSettingsUrl());
|
||||
appendText("\n");
|
||||
}
|
||||
|
||||
if (inFooter) {
|
||||
appendText("\n");
|
||||
} else {
|
||||
openFooter();
|
||||
}
|
||||
appendText("Gerrit-MessageType: " + messageClass + "\n");
|
||||
appendText("Gerrit-Project: " + projectName + "\n");
|
||||
appendText("Gerrit-Branch: " + change.getDest().getShortName() + "\n");
|
||||
appendText("Gerrit-Owner: " + getNameEmailFor(change.getOwner()) + "\n");
|
||||
|
||||
appendText(velocifyFile("ChangeFooter.vm"));
|
||||
try {
|
||||
HashSet<Account.Id> reviewers = new HashSet<Account.Id>();
|
||||
for (PatchSetApproval p : args.db.get().patchSetApprovals().byChange(
|
||||
|
@ -158,8 +135,6 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||
setListIdHeader();
|
||||
setChangeUrlHeader();
|
||||
setCommitIdHeader();
|
||||
|
||||
inFooter = false;
|
||||
}
|
||||
|
||||
private void setListIdHeader() {
|
||||
|
@ -223,13 +198,6 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||
return r.toString();
|
||||
}
|
||||
|
||||
private void openFooter() {
|
||||
if (!inFooter) {
|
||||
inFooter = true;
|
||||
appendText("-- \n");
|
||||
}
|
||||
}
|
||||
|
||||
/** Format the sender's "cover letter", {@link #getCoverLetter()}. */
|
||||
protected void formatCoverLetter() {
|
||||
final String cover = getCoverLetter();
|
||||
|
|
|
@ -168,7 +168,7 @@ public abstract class OutgoingEmail {
|
|||
}
|
||||
}
|
||||
|
||||
protected String getGerritHost() {
|
||||
public String getGerritHost() {
|
||||
if (getGerritUrl() != null) {
|
||||
try {
|
||||
return new URL(getGerritUrl()).getHost();
|
||||
|
@ -194,7 +194,7 @@ public abstract class OutgoingEmail {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected String getGerritUrl() {
|
||||
public String getGerritUrl() {
|
||||
return args.urlProvider.get();
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ public abstract class OutgoingEmail {
|
|||
return name;
|
||||
}
|
||||
|
||||
protected String getNameEmailFor(Account.Id accountId) {
|
||||
public String getNameEmailFor(Account.Id accountId) {
|
||||
AccountState who = args.accountCache.get(accountId);
|
||||
String name = who.getAccount().getFullName();
|
||||
String email = who.getAccount().getPreferredEmail();
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
## Copyright (C) 2010 The Android Open Source Project
|
||||
##
|
||||
## Licensed under the Apache License, Version 2.0 (the "License");
|
||||
## you may not use this file except in compliance with the License.
|
||||
## You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an "AS IS" BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
##
|
||||
##
|
||||
## Template Type:
|
||||
## -------------
|
||||
## This is a velocity mail template, see: http://velocity.apache.org and the
|
||||
## gerrit-docs:config-mail.txt for more info on modifying gerrit mail templates.
|
||||
##
|
||||
## Template File Names and extensions:
|
||||
## ----------------------------------
|
||||
## Gerrit will use templates ending in ".vm" but will ignore templates ending
|
||||
## in ".vm.example". If a .vm template does not exist, the default internal
|
||||
## gerrit template which is the same as the .vm.example will be used. If you
|
||||
## want to override the default template, copy the .vm.exmaple file to a .vm
|
||||
## file and edit it appropriately.
|
||||
##
|
||||
## This Template:
|
||||
## --------------
|
||||
## The ChangeFooter.vm template will determine the contents of the footer
|
||||
## text that will be appended to ALL emails related to changes.
|
||||
##
|
||||
--
|
||||
#if ($email.changeUrl)
|
||||
To view, visit $email.changeUrl
|
||||
#set ($notblank = 1)
|
||||
#end
|
||||
#if ($email.settingsUrl)
|
||||
To unsubscribe, visit $email.settingsUrl
|
||||
#set ($notblank = 1)
|
||||
#end
|
||||
#if ($notblank == 1)
|
||||
|
||||
#end
|
||||
Gerrit-MessageType: $messageClass
|
||||
Gerrit-Project: $projectName
|
||||
Gerrit-Branch: $branch.shortName
|
||||
Gerrit-Owner: $email.getNameEmailFor($change.owner)
|
Loading…
Reference in New Issue