diff --git a/cmd/main.go b/cmd/main.go index fd648946ef..7251bd09a3 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -165,6 +165,7 @@ func NewMainApp(appVer AppVersion) *cli.App { app.Commands = append(app.Commands, subCmdWithConfig...) app.Commands = append(app.Commands, subCmdStandalone...) + setting.InitGiteaEnvVars() return app } diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go index 75044d19e8..43d084845c 100644 --- a/models/unittest/testdb.go +++ b/models/unittest/testdb.go @@ -59,6 +59,7 @@ func InitSettings() { _ = hash.Register("dummy", hash.NewDummyHasher) setting.PasswordHashAlgo, _ = hash.SetDefaultPasswordHashAlgorithm("dummy") + setting.InitGiteaEnvVars() } // TestOptions represents test options diff --git a/modules/setting/config_env.go b/modules/setting/config_env.go index dfcb7db3c8..f05e8a4d7b 100644 --- a/modules/setting/config_env.go +++ b/modules/setting/config_env.go @@ -166,3 +166,8 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) { } return changed } + +// InitGiteaEnvVars initilises the environment for gitea +func InitGiteaEnvVars() { + _ = os.Unsetenv("XDG_CONFIG_HOME") // unset if set as HOME is managed by gitea +}