refactor: clarify GOOS detection (#39620)

Introduce `consts.IsWindows`, now it's clearer to see how Windows build works
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-10-06 08:22:36 +00:00
1 parent 052f660ba5
commit 1065f03454
16 files changed
+44 -37

No files matched your search

-9
View File
@@ -10,7 +10,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"gitea.dev/modules/cache"
@@ -126,16 +125,8 @@ func checkGitVersionCompatibility(gitVer *version.Version) error {
func ensureGitVersion() error {
if !DefaultFeatures().CheckVersionAtLeast(RequiredVersion) {
moreHint := "get git: https://git-scm.com/downloads"
if runtime.GOOS == "linux" {
// there are a lot of CentOS/RHEL users using old git, so we add a special hint for them
if _, err := os.Stat("/etc/redhat-release"); err == nil {
// ius.io is the recommended official(git-scm.com) method to install git
moreHint = "get git: https://git-scm.com/downloads/linux and https://ius.io"
}
}
return fmt.Errorf("installed git version %q is not supported, Gitea requires git version >= %q, %s", DefaultFeatures().gitVersion.Original(), RequiredVersion, moreHint)
}
if err := checkGitVersionCompatibility(DefaultFeatures().gitVersion); err != nil {
return fmt.Errorf("installed git version %s has a known compatibility issue with Gitea: %w, please upgrade (or downgrade) git", DefaultFeatures().gitVersion.String(), err)
}