chore: refactor StaticRootPath (#39384)

When need to use some settings in testing code, always call `SetupGiteaTestEnv`
This commit is contained in:
wxiaoguang
2026-09-22 22:49:36 +08:00
committed by GitHub
parent de5913d647
commit 7637b1b816
2 changed files with 3 additions and 4 deletions
+2 -3
View File
@@ -13,6 +13,7 @@ import (
"time" "time"
"gitea.dev/modules/log" "gitea.dev/modules/log"
"gitea.dev/modules/util"
) )
// Scheme describes protocol types // Scheme describes protocol types
@@ -272,9 +273,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false) RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false)
PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80") PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
RedirectorUseProxyProtocol = sec.Key("REDIRECTOR_USE_PROXY_PROTOCOL").MustBool(UseProxyProtocol) RedirectorUseProxyProtocol = sec.Key("REDIRECTOR_USE_PROXY_PROTOCOL").MustBool(UseProxyProtocol)
if len(StaticRootPath) == 0 { StaticRootPath = util.IfZero(StaticRootPath, AppWorkPath)
StaticRootPath = AppWorkPath
}
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath) StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath)
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour) StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
AppDataPath = sec.Key("APP_DATA_PATH").MustString(filepath.Join(AppWorkPath, "data")) AppDataPath = sec.Key("APP_DATA_PATH").MustString(filepath.Join(AppWorkPath, "data"))
+1 -1
View File
@@ -26,7 +26,7 @@ const (
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
setting.StaticRootPath = "../../" setting.SetupGiteaTestEnv()
setting.Names = []string{"english"} setting.Names = []string{"english"}
setting.Langs = []string{"en-US"} setting.Langs = []string{"en-US"}
// setup // setup