summaryrefslogtreecommitdiffstats
path: root/services/context
diff options
context:
space:
mode:
authorEarl Warren <earl-warren@noreply.codeberg.org>2024-05-08 00:47:53 +0200
committerEarl Warren <earl-warren@noreply.codeberg.org>2024-05-08 00:47:53 +0200
commita2c8fe0370156cb73ca64d84a86ef63359a69567 (patch)
tree3def696e4fb92111e1f3ca9df927d1b765794059 /services/context
parentMerge pull request 'Update module github.com/PuerkitoBio/goquery to v1.9.2' (... (diff)
parentDon't only list code-enabled repositories when using repository API (#30817) (diff)
downloadforgejo-a2c8fe0370156cb73ca64d84a86ef63359a69567.tar.xz
forgejo-a2c8fe0370156cb73ca64d84a86ef63359a69567.zip
Merge pull request '[gitea] week 2024-19 cherry pick (gitea-github/main -> forgejo)' (#3639) from earl-warren/wcp/2024-19 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3639 Reviewed-by: Gergely Nagy <algernon@noreply.codeberg.org>
Diffstat (limited to 'services/context')
-rw-r--r--services/context/base.go4
-rw-r--r--services/context/context_response.go3
-rw-r--r--services/context/repo.go8
3 files changed, 7 insertions, 8 deletions
diff --git a/services/context/base.go b/services/context/base.go
index 25ff935055..0259e0d806 100644
--- a/services/context/base.go
+++ b/services/context/base.go
@@ -234,9 +234,7 @@ func (b *Base) plainTextInternal(skip, status int, bs []byte) {
b.Resp.Header().Set("Content-Type", "text/plain;charset=utf-8")
b.Resp.Header().Set("X-Content-Type-Options", "nosniff")
b.Resp.WriteHeader(status)
- if _, err := b.Resp.Write(bs); err != nil {
- log.ErrorWithSkip(skip, "plainTextInternal (status=%d): write bytes failed: %v", status, err)
- }
+ _, _ = b.Resp.Write(bs)
}
// PlainTextBytes renders bytes as plain text
diff --git a/services/context/context_response.go b/services/context/context_response.go
index 2f2d7b0e1b..f36b834a44 100644
--- a/services/context/context_response.go
+++ b/services/context/context_response.go
@@ -13,6 +13,7 @@ import (
"path"
"strconv"
"strings"
+ "syscall"
"time"
user_model "code.gitea.io/gitea/models/user"
@@ -80,7 +81,7 @@ func (ctx *Context) HTML(status int, name base.TplName) {
}
err := ctx.Render.HTML(ctx.Resp, status, string(name), ctx.Data, ctx.TemplateContext)
- if err == nil {
+ if err == nil || errors.Is(err, syscall.EPIPE) {
return
}
diff --git a/services/context/repo.go b/services/context/repo.go
index 3e30f2ba97..54453cc2d9 100644
--- a/services/context/repo.go
+++ b/services/context/repo.go
@@ -810,7 +810,7 @@ func (rt RepoRefType) RefTypeIncludesTags() bool {
return false
}
-func getRefNameFromPath(ctx *Base, repo *Repository, path string, isExist func(string) bool) string {
+func getRefNameFromPath(repo *Repository, path string, isExist func(string) bool) string {
refName := ""
parts := strings.Split(path, "/")
for i, part := range parts {
@@ -846,7 +846,7 @@ func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string {
repo.TreePath = path
return repo.Repository.DefaultBranch
case RepoRefBranch:
- ref := getRefNameFromPath(ctx, repo, path, repo.GitRepo.IsBranchExist)
+ ref := getRefNameFromPath(repo, path, repo.GitRepo.IsBranchExist)
if len(ref) == 0 {
// check if ref is HEAD
parts := strings.Split(path, "/")
@@ -856,7 +856,7 @@ func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string {
}
// maybe it's a renamed branch
- return getRefNameFromPath(ctx, repo, path, func(s string) bool {
+ return getRefNameFromPath(repo, path, func(s string) bool {
b, exist, err := git_model.FindRenamedBranch(ctx, repo.Repository.ID, s)
if err != nil {
log.Error("FindRenamedBranch: %v", err)
@@ -876,7 +876,7 @@ func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string {
return ref
case RepoRefTag:
- return getRefNameFromPath(ctx, repo, path, repo.GitRepo.IsTagExist)
+ return getRefNameFromPath(repo, path, repo.GitRepo.IsTagExist)
case RepoRefCommit:
parts := strings.Split(path, "/")