diff options
author | Garionion <github@entr0py.de> | 2021-12-08 08:34:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 15:34:23 +0800 |
commit | b59875aa123f2cc3a5026d30ac557e99c05603a6 (patch) | |
tree | 7c8fcc51e1a80a87e035c5eded19e0da69429d43 /modules/setting | |
parent | 0ff18a808c7c14d42ea2325b5d9623f7a30d9107 (diff) | |
download | gitea-b59875aa123f2cc3a5026d30ac557e99c05603a6.tar.gz gitea-b59875aa123f2cc3a5026d30ac557e99c05603a6.zip |
allways set a message-id on mails (#17900)
* allways set a message-id on mails
* Add unit tests for mailer & Message-ID
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/setting')
-rw-r--r-- | modules/setting/setting.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 8b67a45175..83904080de 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -548,17 +548,17 @@ func SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath string) // LoadFromExisting initializes setting options from an existing config file (app.ini) func LoadFromExisting() { - loadFromConf(false) + loadFromConf(false, "") } // LoadAllowEmpty initializes setting options, it's also fine that if the config file (app.ini) doesn't exist func LoadAllowEmpty() { - loadFromConf(true) + loadFromConf(true, "") } // LoadForTest initializes setting options for tests -func LoadForTest() { - loadFromConf(true) +func LoadForTest(extraConfigs ...string) { + loadFromConf(true, strings.Join(extraConfigs, "\n")) if err := PrepareAppDataPath(); err != nil { log.Fatal("Can not prepare APP_DATA_PATH: %v", err) } @@ -566,7 +566,7 @@ func LoadForTest() { // loadFromConf initializes configuration context. // NOTE: do not print any log except error. -func loadFromConf(allowEmpty bool) { +func loadFromConf(allowEmpty bool, extraConfig string) { Cfg = ini.Empty() if WritePIDFile && len(PIDFile) > 0 { @@ -585,6 +585,12 @@ func loadFromConf(allowEmpty bool) { log.Fatal("Unable to find configuration file: %q.\nEnsure you are running in the correct environment or set the correct configuration file with -c.", CustomConf) } // else: no config file, a config file might be created at CustomConf later (might not) + if extraConfig != "" { + if err = Cfg.Append([]byte(extraConfig)); err != nil { + log.Fatal("Unable to append more config: %v", err) + } + } + Cfg.NameMapper = ini.SnackCase homeDir, err := com.HomeDir() |