From 6208d5f5c257602a22bab3c3caf8426f9e190431 Mon Sep 17 00:00:00 2001 From: JonRB <4564448+eeyrjmr@users.noreply.github.com> Date: Wed, 1 Jan 2025 22:37:35 +0000 Subject: [PATCH] unset XDG_HOME_CONFIG as gitea manages configuration locations (#33067) unset XDG_CONFIG_HOME early to enable gitea to manage git configuration. simple error checking to satisfy the linting. Closes #33039 --------- Co-authored-by: wxiaoguang (cherry picked from commit 233b7959e0518c47ef83c6a80c617546983433eb) --- cmd/main.go | 1 + models/unittest/testdb.go | 1 + modules/setting/config_env.go | 5 +++++ 3 files changed, 7 insertions(+) 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 +}