1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor package (routes and error handling, npm peer dependency) (#33111)

This commit is contained in:
wxiaoguang
2025-01-06 22:45:20 +08:00
committed by GitHub
parent ef736b7e27
commit 80e4f4c4eb
28 changed files with 153 additions and 244 deletions

View File

@@ -188,7 +188,7 @@ func GetRawFileOrLFS(ctx *context.APIContext) {
meta, err := git_model.GetLFSMetaObjectByOid(ctx, ctx.Repo.Repository.ID, pointer.Oid)
// If there isn't one, just serve the data directly
if err == git_model.ErrLFSObjectNotExist {
if errors.Is(err, git_model.ErrLFSObjectNotExist) {
// Handle caching for the blob SHA (not the LFS object OID)
if httpcache.HandleGenericETagTimeCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`, lastModified) {
return

View File

@@ -4,6 +4,7 @@
package repo
import (
"errors"
"net/http"
"code.gitea.io/gitea/modules/git"
@@ -82,7 +83,7 @@ func GetGitHook(ctx *context.APIContext) {
hookID := ctx.PathParam("id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
if err != nil {
if err == git.ErrNotValidHook {
if errors.Is(err, git.ErrNotValidHook) {
ctx.NotFound()
} else {
ctx.Error(http.StatusInternalServerError, "GetHook", err)
@@ -129,7 +130,7 @@ func EditGitHook(ctx *context.APIContext) {
hookID := ctx.PathParam("id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
if err != nil {
if err == git.ErrNotValidHook {
if errors.Is(err, git.ErrNotValidHook) {
ctx.NotFound()
} else {
ctx.Error(http.StatusInternalServerError, "GetHook", err)
@@ -178,7 +179,7 @@ func DeleteGitHook(ctx *context.APIContext) {
hookID := ctx.PathParam("id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
if err != nil {
if err == git.ErrNotValidHook {
if errors.Is(err, git.ErrNotValidHook) {
ctx.NotFound()
} else {
ctx.Error(http.StatusInternalServerError, "GetHook", err)