diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index 8e8080b6225..ae4ea7ea87a 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 12ce37bcef7..8647033923a 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 }