refactor(tests): drop the need to compile gitea binary manually (#12855)

Thanks to forgejo/forgejo!10397 (by @voidcontext), the binary called on git hooks can now be dynamically set.

**This means that we can now run tests without needing to run `make gitea` first**! No more `Could not find gitea binary` or head-banging, when one forgets to re-compile it 🎉

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12855
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
oliverpool
2026-06-02 00:04:50 +02:00
committed by Gusted
parent f102bc2b51
commit d11bd64691
14 changed files with 95 additions and 103 deletions
+2 -1
View File
@@ -130,6 +130,7 @@ func IsCitationFile(entry *git.TreeEntry) bool {
}
// SetupGiteaRoot Sets GITEA_ROOT if it is not already set and returns the value
// TODO: move to a test folder (e.g. models/unittest/) since this isn't called outside tests
func SetupGiteaRoot() string {
giteaRoot := os.Getenv("GITEA_ROOT")
if giteaRoot == "" {
@@ -142,7 +143,7 @@ func SetupGiteaRoot() string {
giteaRoot = wd
}
}
if _, err := os.Stat(filepath.Join(giteaRoot, "gitea")); os.IsNotExist(err) {
if _, err := os.Stat(filepath.Join(giteaRoot, "go.mod")); os.IsNotExist(err) {
giteaRoot = ""
} else if err := os.Setenv("GITEA_ROOT", giteaRoot); err != nil {
giteaRoot = ""