Fix git empty check and HEAD request (#33690)

This commit is contained in:
wxiaoguang 2025-02-24 10:11:29 +08:00 committed by GitHub
parent 8ae46d9684
commit 56a0a9c750
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 16 deletions

View file

@ -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