Skip to content

Commit fcf459d

Browse files
committed
add context to Size
1 parent 960a844 commit fcf459d

22 files changed

+52
-48
lines changed

modules/git/blob_gogit.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package git
88

99
import (
10+
"context"
1011
"io"
1112

1213
"github.com/go-git/go-git/v5/plumbing"
@@ -27,6 +28,6 @@ func (b *Blob) DataAsync() (io.ReadCloser, error) {
2728
}
2829

2930
// Size returns the uncompressed size of the blob
30-
func (b *Blob) Size() int64 {
31+
func (b *Blob) Size(_ context.Context) int64 {
3132
return b.gogitEncodedObj.Size()
3233
}

modules/git/blob_nogogit.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package git
88
import (
99
"bufio"
1010
"bytes"
11+
"context"
1112
"io"
1213

1314
"code.gitea.io/gitea/modules/log"
@@ -62,12 +63,12 @@ func (b *Blob) DataAsync() (io.ReadCloser, error) {
6263
}
6364

6465
// Size returns the uncompressed size of the blob
65-
func (b *Blob) Size() int64 {
66+
func (b *Blob) Size(ctx context.Context) int64 {
6667
if b.gotSize {
6768
return b.size
6869
}
6970

70-
wr, rd, cancel, err := b.repo.CatFileBatchCheck(b.repo.Ctx)
71+
wr, rd, cancel, err := b.repo.CatFileBatchCheck(ctx)
7172
if err != nil {
7273
log.Debug("error whilst reading size for %s in %s. Error: %v", b.ID.String(), b.repo.Path, err)
7374
return 0

modules/issue/template/unmarshal.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package template
55

66
import (
7+
"context"
78
"fmt"
89
"io"
910
"path"
@@ -42,31 +43,31 @@ func Unmarshal(filename string, content []byte) (*api.IssueTemplate, error) {
4243
}
4344

4445
// UnmarshalFromEntry parses out a valid template from the blob in entry
45-
func UnmarshalFromEntry(entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) {
46-
return unmarshalFromEntry(entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here
46+
func UnmarshalFromEntry(ctx context.Context, entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) {
47+
return unmarshalFromEntry(ctx, entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here
4748
}
4849

4950
// UnmarshalFromCommit parses out a valid template from the commit
50-
func UnmarshalFromCommit(commit *git.Commit, filename string) (*api.IssueTemplate, error) {
51+
func UnmarshalFromCommit(ctx context.Context, commit *git.Commit, filename string) (*api.IssueTemplate, error) {
5152
entry, err := commit.GetTreeEntryByPath(filename)
5253
if err != nil {
5354
return nil, fmt.Errorf("get entry for %q: %w", filename, err)
5455
}
55-
return unmarshalFromEntry(entry, filename)
56+
return unmarshalFromEntry(ctx, entry, filename)
5657
}
5758

5859
// UnmarshalFromRepo parses out a valid template from the head commit of the branch
59-
func UnmarshalFromRepo(repo *git.Repository, branch, filename string) (*api.IssueTemplate, error) {
60+
func UnmarshalFromRepo(ctx context.Context, repo *git.Repository, branch, filename string) (*api.IssueTemplate, error) {
6061
commit, err := repo.GetBranchCommit(branch)
6162
if err != nil {
6263
return nil, fmt.Errorf("get commit on branch %q: %w", branch, err)
6364
}
6465

65-
return UnmarshalFromCommit(commit, filename)
66+
return UnmarshalFromCommit(ctx, commit, filename)
6667
}
6768

68-
func unmarshalFromEntry(entry *git.TreeEntry, filename string) (*api.IssueTemplate, error) {
69-
if size := entry.Blob().Size(); size > setting.UI.MaxDisplayFileSize {
69+
func unmarshalFromEntry(ctx context.Context, entry *git.TreeEntry, filename string) (*api.IssueTemplate, error) {
70+
if size := entry.Blob().Size(ctx); size > setting.UI.MaxDisplayFileSize {
7071
return nil, fmt.Errorf("too large: %v > MaxDisplayFileSize", size)
7172
}
7273

routers/api/v1/repo/file.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func GetRawFileOrLFS(ctx *context.APIContext) {
137137
ctx.RespHeader().Set(giteaObjectTypeHeader, string(files_service.GetObjectTypeFromTreeEntry(entry)))
138138

139139
// LFS Pointer files are at most 1024 bytes - so any blob greater than 1024 bytes cannot be an LFS file
140-
if blob.Size() > 1024 {
140+
if blob.Size(ctx) > 1024 {
141141
// First handle caching for the blob
142142
if httpcache.HandleGenericETagTimeCache(ctx.Req, ctx.Resp, `"`+blob.ID.String()+`"`, lastModified) {
143143
return
@@ -180,7 +180,7 @@ func GetRawFileOrLFS(ctx *context.APIContext) {
180180
}
181181

182182
// OK not cached - serve!
183-
common.ServeContentByReader(ctx.Base, ctx.Repo.TreePath, blob.Size(), bytes.NewReader(buf))
183+
common.ServeContentByReader(ctx.Base, ctx.Repo.TreePath, blob.Size(ctx), bytes.NewReader(buf))
184184
return
185185
}
186186

@@ -194,7 +194,7 @@ func GetRawFileOrLFS(ctx *context.APIContext) {
194194
return
195195
}
196196

197-
common.ServeContentByReader(ctx.Base, ctx.Repo.TreePath, blob.Size(), bytes.NewReader(buf))
197+
common.ServeContentByReader(ctx.Base, ctx.Repo.TreePath, blob.Size(ctx), bytes.NewReader(buf))
198198
return
199199
} else if err != nil {
200200
ctx.APIErrorInternal(err)
@@ -384,7 +384,7 @@ func GetEditorconfig(ctx *context.APIContext) {
384384
// "404":
385385
// "$ref": "#/responses/notFound"
386386

387-
ec, _, err := ctx.Repo.GetEditorconfig(ctx.Repo.Commit)
387+
ec, _, err := ctx.Repo.GetEditorconfig(ctx, ctx.Repo.Commit)
388388
if err != nil {
389389
if git.IsErrNotExist(err) {
390390
ctx.APIErrorNotFound(err)

routers/api/v1/repo/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ func GetIssueTemplates(ctx *context.APIContext) {
12001200
// "$ref": "#/responses/IssueTemplates"
12011201
// "404":
12021202
// "$ref": "#/responses/notFound"
1203-
ret := issue.ParseTemplatesFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo)
1203+
ret := issue.ParseTemplatesFromDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
12041204
if cnt := len(ret.TemplateErrors); cnt != 0 {
12051205
ctx.Resp.Header().Add("X-Gitea-Warning", "error occurs when parsing issue template: count="+strconv.Itoa(cnt))
12061206
}

routers/api/v1/repo/wiki.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func findWikiRepoCommit(ctx *context.APIContext) (*git.Repository, *git.Commit)
502502
// given tree entry, encoded with base64. Writes to ctx if an error occurs.
503503
func wikiContentsByEntry(ctx *context.APIContext, entry *git.TreeEntry) string {
504504
blob := entry.Blob()
505-
if blob.Size() > setting.API.DefaultMaxBlobSize {
505+
if blob.Size(ctx) > setting.API.DefaultMaxBlobSize {
506506
return ""
507507
}
508508
content, err := blob.GetBlobContentBase64()

routers/common/serve.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func ServeBlob(ctx *context.Base, repo *repo_model.Repository, filePath string,
3535
}()
3636

3737
_ = repo.LoadOwner(ctx)
38-
httplib.ServeContentByReader(ctx.Req, ctx.Resp, blob.Size(), dataRc, &httplib.ServeHeaderOptions{
38+
httplib.ServeContentByReader(ctx.Req, ctx.Resp, blob.Size(ctx), dataRc, &httplib.ServeHeaderOptions{
3939
Filename: path.Base(filePath),
4040
CacheIsPublic: !repo.IsPrivate && repo.Owner != nil && repo.Owner.Visibility == structs.VisibleTypePublic,
4141
CacheDuration: setting.StaticCacheTime,

routers/web/repo/blame.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func RefBlame(ctx *context.Context) {
6767
ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/raw/" + ctx.Repo.RefTypeNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)
6868

6969
blob := entry.Blob()
70-
fileSize := blob.Size()
70+
fileSize := blob.Size(ctx)
7171
ctx.Data["FileSize"] = fileSize
7272
ctx.Data["FileName"] = blob.Name()
7373

routers/web/repo/compare.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func setCsvCompareContext(ctx *context.Context) {
137137
return nil, nil, nil
138138
}
139139

140-
if setting.UI.CSV.MaxFileSize != 0 && setting.UI.CSV.MaxFileSize < blob.Size() {
140+
if setting.UI.CSV.MaxFileSize != 0 && setting.UI.CSV.MaxFileSize < blob.Size(ctx) {
141141
return nil, nil, errTooLarge
142142
}
143143

routers/web/repo/editor.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
146146
}
147147

148148
blob := entry.Blob()
149-
if blob.Size() >= setting.UI.MaxDisplayFileSize {
149+
if blob.Size(ctx) >= setting.UI.MaxDisplayFileSize {
150150
ctx.NotFound(err)
151151
return
152152
}
@@ -159,7 +159,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
159159

160160
defer dataRc.Close()
161161

162-
ctx.Data["FileSize"] = blob.Size()
162+
ctx.Data["FileSize"] = blob.Size(ctx)
163163
ctx.Data["FileName"] = blob.Name()
164164

165165
buf := make([]byte, 1024)
@@ -201,7 +201,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
201201

202202
// GetEditorConfig returns a editorconfig JSON string for given treePath or "null"
203203
func GetEditorConfig(ctx *context.Context, treePath string) string {
204-
ec, _, err := ctx.Repo.GetEditorconfig()
204+
ec, _, err := ctx.Repo.GetEditorconfig(ctx)
205205
if err == nil {
206206
def, err := ec.GetDefinitionForFilename(treePath)
207207
if err == nil {

routers/web/repo/issue_list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ func Issues(ctx *context.Context) {
765765
}
766766
ctx.Data["Title"] = ctx.Tr("repo.issues")
767767
ctx.Data["PageIsIssueList"] = true
768-
ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo)
768+
ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
769769
}
770770

771771
issues(ctx, ctx.FormInt64("milestone"), ctx.FormInt64("project"), optional.Some(isPullList))

routers/web/repo/issue_new.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
5353
if ok, _ := commit.HasFile(filename); !ok {
5454
continue
5555
}
56-
template, err := issue_template.UnmarshalFromCommit(commit, filename)
56+
template, err := issue_template.UnmarshalFromCommit(ctx, commit, filename)
5757
if err != nil {
5858
templateErrs[filename] = err
5959
continue
@@ -98,7 +98,7 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
9898
// NewIssue render creating issue page
9999
func NewIssue(ctx *context.Context) {
100100
issueConfig, _ := issue_service.GetTemplateConfigFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo)
101-
hasTemplates := issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo)
101+
hasTemplates := issue_service.HasTemplatesOrContactLinks(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
102102

103103
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
104104
ctx.Data["PageIsIssueList"] = true
@@ -134,7 +134,7 @@ func NewIssue(ctx *context.Context) {
134134
}
135135
ctx.Data["Tags"] = tags
136136

137-
ret := issue_service.ParseTemplatesFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo)
137+
ret := issue_service.ParseTemplatesFromDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
138138
templateLoaded, errs := setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates, pageMetaData)
139139
for k, v := range errs {
140140
ret.TemplateErrors[k] = v
@@ -187,14 +187,14 @@ func NewIssueChooseTemplate(ctx *context.Context) {
187187
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
188188
ctx.Data["PageIsIssueList"] = true
189189

190-
ret := issue_service.ParseTemplatesFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo)
190+
ret := issue_service.ParseTemplatesFromDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
191191
ctx.Data["IssueTemplates"] = ret.IssueTemplates
192192

193193
if len(ret.TemplateErrors) > 0 {
194194
ctx.Flash.Warning(renderErrorOfTemplates(ctx, ret.TemplateErrors), true)
195195
}
196196

197-
if !issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo) {
197+
if !issue_service.HasTemplatesOrContactLinks(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo) {
198198
// The "issues/new" and "issues/new/choose" share the same query parameters "project" and "milestone", if no template here, just redirect to the "issues/new" page with these parameters.
199199
ctx.Redirect(fmt.Sprintf("%s/issues/new?%s", ctx.Repo.Repository.Link(), ctx.Req.URL.RawQuery), http.StatusSeeOther)
200200
return
@@ -329,7 +329,7 @@ func NewIssuePost(ctx *context.Context) {
329329
form := web.GetForm(ctx).(*forms.CreateIssueForm)
330330
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
331331
ctx.Data["PageIsIssueList"] = true
332-
ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo)
332+
ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
333333
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
334334
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
335335
upload.AddUploadContext(ctx, "comment")
@@ -370,7 +370,7 @@ func NewIssuePost(ctx *context.Context) {
370370

371371
content := form.Content
372372
if filename := ctx.Req.Form.Get("template-file"); filename != "" {
373-
if template, err := issue_template.UnmarshalFromRepo(ctx.Repo.GitRepo, ctx.Repo.Repository.DefaultBranch, filename); err == nil {
373+
if template, err := issue_template.UnmarshalFromRepo(ctx, ctx.Repo.GitRepo, ctx.Repo.Repository.DefaultBranch, filename); err == nil {
374374
content = issue_template.RenderToMarkdown(template, ctx.Req.Form)
375375
}
376376
}

routers/web/repo/issue_view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func ViewIssue(ctx *context.Context) {
330330
return
331331
}
332332
ctx.Data["PageIsIssueList"] = true
333-
ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo)
333+
ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
334334
}
335335

336336
ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(unit.TypeProjects)

routers/web/repo/middlewares.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func SetEditorconfigIfExists(ctx *context.Context) {
1818
return
1919
}
2020

21-
ec, _, err := ctx.Repo.GetEditorconfig()
21+
ec, _, err := ctx.Repo.GetEditorconfig(ctx)
2222
if err != nil {
2323
// it used to check `!git.IsErrNotExist(err)` and create a system notice, but it is quite annoying and useless
2424
// because network errors also happen frequently, so we just ignore it

routers/web/repo/milestone.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func MilestoneIssuesAndPulls(ctx *context.Context) {
265265

266266
issues(ctx, milestoneID, projectID, optional.None[bool]())
267267

268-
ret := issue.ParseTemplatesFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo)
268+
ret := issue.ParseTemplatesFromDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo)
269269
ctx.Data["NewIssueChooseTemplate"] = len(ret.IssueTemplates) > 0
270270

271271
ctx.Data["CanWriteIssues"] = ctx.Repo.CanWriteIssuesOrPulls(false)

routers/web/repo/pull.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13181318

13191319
content := form.Content
13201320
if filename := ctx.Req.Form.Get("template-file"); filename != "" {
1321-
if template, err := issue_template.UnmarshalFromRepo(ctx.Repo.GitRepo, ctx.Repo.Repository.DefaultBranch, filename); err == nil {
1321+
if template, err := issue_template.UnmarshalFromRepo(ctx, ctx.Repo.GitRepo, ctx.Repo.Repository.DefaultBranch, filename); err == nil {
13221322
content = issue_template.RenderToMarkdown(template, ctx.Req.Form)
13231323
}
13241324
}

routers/web/repo/view.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ func getFileReader(ctx gocontext.Context, repoID int64, blob *git.Blob) ([]byte,
8080

8181
// FIXME: what happens when README file is an image?
8282
if !isTextFile || !setting.LFS.StartServer {
83-
return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(), nil, st}, nil
83+
return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(ctx), nil, st}, nil
8484
}
8585

8686
pointer, _ := lfs.ReadPointerFromBuffer(buf)
8787
if !pointer.IsValid() { // fallback to plain file
88-
return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(), nil, st}, nil
88+
return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(ctx), nil, st}, nil
8989
}
9090

9191
meta, err := git_model.GetLFSMetaObjectByOid(ctx, repoID, pointer.Oid)
9292
if err != nil { // fallback to plain file
9393
log.Warn("Unable to access LFS pointer %s in repo %d: %v", pointer.Oid, repoID, err)
94-
return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(), nil, st}, nil
94+
return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(ctx), nil, st}, nil
9595
}
9696

9797
dataRc.Close()

routers/web/repo/view_file.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) {
5757
}
5858

5959
if ctx.Repo.TreePath == ".editorconfig" {
60-
_, editorconfigWarning, editorconfigErr := ctx.Repo.GetEditorconfig(ctx.Repo.Commit)
60+
_, editorconfigWarning, editorconfigErr := ctx.Repo.GetEditorconfig(ctx, ctx.Repo.Commit)
6161
if editorconfigWarning != nil {
6262
ctx.Data["FileWarning"] = strings.TrimSpace(editorconfigWarning.Error())
6363
}

services/context/repo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (r *Repository) RefTypeNameSubURL() string {
203203

204204
// GetEditorconfig returns the .editorconfig definition if found in the
205205
// HEAD of the default repo branch.
206-
func (r *Repository) GetEditorconfig(optCommit ...*git.Commit) (cfg *editorconfig.Editorconfig, warning, err error) {
206+
func (r *Repository) GetEditorconfig(ctx context.Context, optCommit ...*git.Commit) (cfg *editorconfig.Editorconfig, warning, err error) {
207207
if r.GitRepo == nil {
208208
return nil, nil, nil
209209
}
@@ -222,7 +222,7 @@ func (r *Repository) GetEditorconfig(optCommit ...*git.Commit) (cfg *editorconfi
222222
if err != nil {
223223
return nil, nil, err
224224
}
225-
if treeEntry.Blob().Size() >= setting.UI.MaxDisplayFileSize {
225+
if treeEntry.Blob().Size(ctx) >= setting.UI.MaxDisplayFileSize {
226226
return nil, nil, git.ErrNotExist{ID: "", RelPath: ".editorconfig"}
227227
}
228228
reader, err := treeEntry.Blob().DataAsync()

services/issue/template.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package issue
55

66
import (
7+
"context"
78
"fmt"
89
"io"
910
"net/url"
@@ -109,7 +110,7 @@ func IsTemplateConfig(path string) bool {
109110

110111
// ParseTemplatesFromDefaultBranch parses the issue templates in the repo's default branch,
111112
// returns valid templates and the errors of invalid template files (the errors map is guaranteed to be non-nil).
112-
func ParseTemplatesFromDefaultBranch(repo *repo.Repository, gitRepo *git.Repository) (ret struct {
113+
func ParseTemplatesFromDefaultBranch(ctx context.Context, repo *repo.Repository, gitRepo *git.Repository) (ret struct {
113114
IssueTemplates []*api.IssueTemplate
114115
TemplateErrors map[string]error
115116
},
@@ -140,7 +141,7 @@ func ParseTemplatesFromDefaultBranch(repo *repo.Repository, gitRepo *git.Reposit
140141
continue
141142
}
142143
fullName := path.Join(dirName, entry.Name())
143-
if it, err := template.UnmarshalFromEntry(entry, dirName); err != nil {
144+
if it, err := template.UnmarshalFromEntry(ctx, entry, dirName); err != nil {
144145
ret.TemplateErrors[fullName] = err
145146
} else {
146147
if !strings.HasPrefix(it.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref>
@@ -178,8 +179,8 @@ func GetTemplateConfigFromDefaultBranch(repo *repo.Repository, gitRepo *git.Repo
178179
return GetDefaultTemplateConfig(), nil
179180
}
180181

181-
func HasTemplatesOrContactLinks(repo *repo.Repository, gitRepo *git.Repository) bool {
182-
ret := ParseTemplatesFromDefaultBranch(repo, gitRepo)
182+
func HasTemplatesOrContactLinks(ctx context.Context, repo *repo.Repository, gitRepo *git.Repository) bool {
183+
ret := ParseTemplatesFromDefaultBranch(ctx, repo, gitRepo)
183184
if len(ret.IssueTemplates) > 0 {
184185
return true
185186
}

services/markup/renderhelper_codepreview.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func renderRepoFileCodePreview(ctx context.Context, opts markup.RenderCodePrevie
6767
return "", err
6868
}
6969

70-
if blob.Size() > setting.UI.MaxDisplayFileSize {
70+
if blob.Size(ctx) > setting.UI.MaxDisplayFileSize {
7171
return "", fmt.Errorf("file is too large")
7272
}
7373

0 commit comments

Comments
 (0)