aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-05-07 00:34:16 +0800
committerGitHub <noreply@github.com>2024-05-06 18:34:16 +0200
commit7c613f100e032f821df88a75954fc50b1cf2f926 (patch)
tree18f73e576eb62a593395919b765e7583f1a1ba06 /routers
parent8e8ca6c6530e49e39f970bdfa84716ffda8973d0 (diff)
downloadgitea-7c613f100e032f821df88a75954fc50b1cf2f926.tar.gz
gitea-7c613f100e032f821df88a75954fc50b1cf2f926.zip
Make sure git version&feature are always prepared (#30877)
Otherwise there would be more similar issues like #29287
Diffstat (limited to 'routers')
-rw-r--r--routers/init.go6
-rw-r--r--routers/private/hook_pre_receive.go2
-rw-r--r--routers/private/hook_proc_receive.go2
-rw-r--r--routers/private/serv.go2
-rw-r--r--routers/web/admin/config.go2
-rw-r--r--routers/web/misc/misc.go2
-rw-r--r--routers/web/repo/githttp.go2
-rw-r--r--routers/web/repo/repo.go2
8 files changed, 12 insertions, 8 deletions
diff --git a/routers/init.go b/routers/init.go
index 030ef3c740..56c95cd1ca 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -25,6 +25,7 @@ import (
"code.gitea.io/gitea/modules/system"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/translation"
+ "code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/modules/web/routing"
actions_router "code.gitea.io/gitea/routers/api/actions"
@@ -112,7 +113,10 @@ func InitWebInstallPage(ctx context.Context) {
// InitWebInstalled is for global installed configuration.
func InitWebInstalled(ctx context.Context) {
mustInitCtx(ctx, git.InitFull)
- log.Info("Git version: %s (home: %s)", git.VersionInfo(), git.HomeDir())
+ log.Info("Git version: %s (home: %s)", git.DefaultFeatures().VersionInfo(), git.HomeDir())
+ if !git.DefaultFeatures().SupportHashSha256 {
+ log.Warn("sha256 hash support is disabled - requires Git >= 2.42." + util.Iif(git.DefaultFeatures().UsingGogit, " Gogit is currently unsupported.", ""))
+ }
// Setup i18n
translation.InitLocales(ctx)
diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go
index 7189fd715c..0a3c8e2559 100644
--- a/routers/private/hook_pre_receive.go
+++ b/routers/private/hook_pre_receive.go
@@ -122,7 +122,7 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) {
preReceiveBranch(ourCtx, oldCommitID, newCommitID, refFullName)
case refFullName.IsTag():
preReceiveTag(ourCtx, refFullName)
- case git.DefaultFeatures.SupportProcReceive && refFullName.IsFor():
+ case git.DefaultFeatures().SupportProcReceive && refFullName.IsFor():
preReceiveFor(ourCtx, refFullName)
default:
ourCtx.AssertCanWriteCode()
diff --git a/routers/private/hook_proc_receive.go b/routers/private/hook_proc_receive.go
index cee3bbdd12..efb3f5831e 100644
--- a/routers/private/hook_proc_receive.go
+++ b/routers/private/hook_proc_receive.go
@@ -18,7 +18,7 @@ import (
// HookProcReceive proc-receive hook - only handles agit Proc-Receive requests at present
func HookProcReceive(ctx *gitea_context.PrivateContext) {
opts := web.GetForm(ctx).(*private.HookOptions)
- if !git.DefaultFeatures.SupportProcReceive {
+ if !git.DefaultFeatures().SupportProcReceive {
ctx.Status(http.StatusNotFound)
return
}
diff --git a/routers/private/serv.go b/routers/private/serv.go
index 85368a0aed..1c309865d7 100644
--- a/routers/private/serv.go
+++ b/routers/private/serv.go
@@ -297,7 +297,7 @@ func ServCommand(ctx *context.PrivateContext) {
}
} else {
// Because of the special ref "refs/for" we will need to delay write permission check
- if git.DefaultFeatures.SupportProcReceive && unitType == unit.TypeCode {
+ if git.DefaultFeatures().SupportProcReceive && unitType == unit.TypeCode {
mode = perm.AccessModeRead
}
diff --git a/routers/web/admin/config.go b/routers/web/admin/config.go
index 48f80dbbf1..fd8c73b62d 100644
--- a/routers/web/admin/config.go
+++ b/routers/web/admin/config.go
@@ -112,7 +112,7 @@ func Config(ctx *context.Context) {
ctx.Data["OfflineMode"] = setting.OfflineMode
ctx.Data["RunUser"] = setting.RunUser
ctx.Data["RunMode"] = util.ToTitleCase(setting.RunMode)
- ctx.Data["GitVersion"] = git.VersionInfo()
+ ctx.Data["GitVersion"] = git.DefaultFeatures().VersionInfo()
ctx.Data["AppDataPath"] = setting.AppDataPath
ctx.Data["RepoRootPath"] = setting.RepoRootPath
diff --git a/routers/web/misc/misc.go b/routers/web/misc/misc.go
index ac5496ce91..caaca7f521 100644
--- a/routers/web/misc/misc.go
+++ b/routers/web/misc/misc.go
@@ -15,7 +15,7 @@ import (
)
func SSHInfo(rw http.ResponseWriter, req *http.Request) {
- if !git.DefaultFeatures.SupportProcReceive {
+ if !git.DefaultFeatures().SupportProcReceive {
rw.WriteHeader(http.StatusNotFound)
return
}
diff --git a/routers/web/repo/githttp.go b/routers/web/repo/githttp.go
index 8fb6d93068..f0579b56ea 100644
--- a/routers/web/repo/githttp.go
+++ b/routers/web/repo/githttp.go
@@ -183,7 +183,7 @@ func httpBase(ctx *context.Context) *serviceHandler {
if repoExist {
// Because of special ref "refs/for" .. , need delay write permission check
- if git.DefaultFeatures.SupportProcReceive {
+ if git.DefaultFeatures().SupportProcReceive {
accessMode = perm.AccessModeRead
}
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 4e448933c7..48be1c2296 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -180,7 +180,7 @@ func Create(ctx *context.Context) {
ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo()
ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit()
- ctx.Data["SupportedObjectFormats"] = git.SupportedObjectFormats
+ ctx.Data["SupportedObjectFormats"] = git.DefaultFeatures().SupportedObjectFormats
ctx.Data["DefaultObjectFormat"] = git.Sha1ObjectFormat
ctx.HTML(http.StatusOK, tplCreate)