Merge "Honor the sendmail.smtpUser from gerrit.config on upgrade"

This commit is contained in:
Shawn Pearce
2012-05-29 19:04:05 -07:00
committed by gerrit code review

View File

@@ -28,12 +28,14 @@ import com.google.inject.Singleton;
class InitSendEmail implements InitStep { class InitSendEmail implements InitStep {
private final ConsoleUI ui; private final ConsoleUI ui;
private final Section sendemail; private final Section sendemail;
private final SitePaths site;
@Inject @Inject
InitSendEmail(final ConsoleUI ui, final SitePaths site, InitSendEmail(final ConsoleUI ui, final SitePaths site,
final Section.Factory sections) { final Section.Factory sections) {
this.ui = ui; this.ui = ui;
this.sendemail = sections.get("sendemail"); this.sendemail = sections.get("sendemail");
this.site = site;
} }
public void run() { public void run() {
@@ -49,7 +51,9 @@ class InitSendEmail implements InitStep {
true); true);
String username = null; String username = null;
if ((enc != null && enc != Encryption.NONE) || !isLocal(hostname)) { if (site.gerrit_config.exists()) {
username = sendemail.get("smtpUser");
} else if ((enc != null && enc != Encryption.NONE) || !isLocal(hostname)) {
username = username(); username = username();
} }
sendemail.string("SMTP username", "smtpUser", username); sendemail.string("SMTP username", "smtpUser", username);