From acb57e503129d7ef4fcba5d398d78c84d9b896b8 Mon Sep 17 00:00:00 2001 From: badhezi Date: Mon, 12 May 2025 17:07:15 +0300 Subject: [PATCH] lint, err handle --- routers/api/packages/api.go | 1 + routers/web/repo/compare.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index 8e8080b622..ae4ea7ea87 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -685,6 +685,7 @@ func CommonRoutes() *web.Router { // https://github.com/opencontainers/distribution-spec/blob/main/spec.md func ContainerRoutes() *web.Router { r := web.NewRouter() + r.Use(context.PackageContexter()) verifyAuth(r, []auth.Method{ diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 12ce37bcef..8647033923 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -235,7 +235,6 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo { if strings.HasSuffix(infoPath, ".diff") { ci.RawDiffType = git.RawDiffNormal infoPath = strings.TrimSuffix(infoPath, ".diff") - } else if strings.HasSuffix(infoPath, ".patch") { ci.RawDiffType = git.RawDiffPatch infoPath = strings.TrimSuffix(infoPath, ".patch") @@ -756,7 +755,11 @@ func CompareDiff(ctx *context.Context) { } if ci.RawDiffType != "" { - git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch, ci.RawDiffType, "", ctx.Resp) + err := git.GetRepoRawDiffForFile(ci.HeadGitRepo, ci.BaseBranch, ci.HeadBranch, ci.RawDiffType, "", ctx.Resp) + if err != nil { + ctx.ServerError("GetRepoRawDiffForFile", err) + return + } ctx.Resp.Flush() return }