From 56a0a9c750b4cd48ca44a22ff0c860b9d035c950 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 24 Feb 2025 10:11:29 +0800 Subject: Fix git empty check and HEAD request (#33690) --- services/context/api.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'services') diff --git a/services/context/api.go b/services/context/api.go index 230c3456d1..c163de036c 100644 --- a/services/context/api.go +++ b/services/context/api.go @@ -291,6 +291,11 @@ func RepoRefForAPI(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { ctx := GetAPIContext(req) + if ctx.Repo.Repository.IsEmpty { + ctx.APIErrorNotFound("repository is empty") + return + } + if ctx.Repo.GitRepo == nil { ctx.APIErrorInternal(fmt.Errorf("no open git repo")) return -- cgit v1.2.3