mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -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()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user