diff --git a/cmd/main.go b/cmd/main.go index b48a6143d7..9a28722b4b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -206,6 +206,7 @@ func innerNewMainApp(version, versionExtra string, subCmdsStandaloneArgs, subCmd 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 94a3253644..8f79ff7f1a 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 fa0100dba2..ab7fcb501a 100644 --- a/modules/setting/config_env.go +++ b/modules/setting/config_env.go @@ -168,3 +168,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 +}