Clean up Makefile, tests and legacy code (#36638)

This simplifies the Makefile by removing the whole-file wrapping that
creates a tempdir introduced by
https://github.com/go-gitea/gitea/pull/11126. REPO_TEST_DIR is removed
as well.

Also clean up a lot of legacy code: unnecessary XSS test, incorrect test
env init, unused "_old_uid" hack, etc

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-02-19 02:23:32 +01:00
committed by GitHub
parent 147bdfce0d
commit 5e9b9b33d1
29 changed files with 132 additions and 301 deletions

View File

@@ -13,7 +13,18 @@ import (
"code.gitea.io/gitea/modules/util"
)
func SetupGiteaTestEnv() string {
var giteaTestSourceRoot *string
func GetGiteaTestSourceRoot() string {
return *giteaTestSourceRoot
}
func SetupGiteaTestEnv() {
if giteaTestSourceRoot != nil {
return // already initialized
}
IsInTesting = true
giteaRoot := os.Getenv("GITEA_TEST_ROOT")
if giteaRoot == "" {
_, filename, _, _ := runtime.Caller(0)
@@ -27,6 +38,7 @@ func SetupGiteaTestEnv() string {
appWorkPathBuiltin = giteaRoot
AppWorkPath = giteaRoot
AppPath = filepath.Join(giteaRoot, "gitea") + util.Iif(IsWindows, ".exe", "")
StaticRootPath = giteaRoot // need to load assets (options, public) from the source code directory for testing
// giteaConf (GITEA_CONF) must be relative because it is used in the git hooks as "$GITEA_ROOT/$GITEA_CONF"
giteaConf := os.Getenv("GITEA_TEST_CONF")
@@ -56,6 +68,5 @@ func SetupGiteaTestEnv() string {
// TODO: some git repo hooks (test fixtures) still use these env variables, need to be refactored in the future
_ = os.Setenv("GITEA_ROOT", giteaRoot)
_ = os.Setenv("GITEA_CONF", giteaConf) // test fixture git hooks use "$GITEA_ROOT/$GITEA_CONF" in their scripts
return giteaRoot
giteaTestSourceRoot = &giteaRoot
}