forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
* upstream/main: Start using template context function (go-gitea#26254) Allow package cleanup from admin page (go-gitea#25307) Fix text truncate (go-gitea#26354) Fix incorrect sort link with `.profile` repository (go-gitea#26374) Use more `IssueList` instead of `[]*Issue` (go-gitea#26369) Rename code_langauge.go to code_language.go (go-gitea#26377) Add changelog for 1.20.3 (go-gitea#26373) Do not highlight `#number` in documents (go-gitea#26365) Bypass MariaDB performance bug of the "IN" sub-query, fix incorrect IssueIndex (go-gitea#26279) Fix nil pointer dereference error when open link with invalid pull index (go-gitea#26353)
- Loading branch information
Showing
35 changed files
with
336 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package context | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"time" | ||
|
||
"code.gitea.io/gitea/modules/log" | ||
) | ||
|
||
var _ context.Context = TemplateContext(nil) | ||
|
||
func NewTemplateContext(ctx context.Context) TemplateContext { | ||
return TemplateContext{"_ctx": ctx} | ||
} | ||
|
||
func (c TemplateContext) parentContext() context.Context { | ||
return c["_ctx"].(context.Context) | ||
} | ||
|
||
func (c TemplateContext) Deadline() (deadline time.Time, ok bool) { | ||
return c.parentContext().Deadline() | ||
} | ||
|
||
func (c TemplateContext) Done() <-chan struct{} { | ||
return c.parentContext().Done() | ||
} | ||
|
||
func (c TemplateContext) Err() error { | ||
return c.parentContext().Err() | ||
} | ||
|
||
func (c TemplateContext) Value(key any) any { | ||
return c.parentContext().Value(key) | ||
} | ||
|
||
// DataRaceCheck checks whether the template context function "ctx()" returns the consistent context | ||
// as the current template's rendering context (request context), to help to find data race issues as early as possible. | ||
// When the code is proven to be correct and stable, this function should be removed. | ||
func (c TemplateContext) DataRaceCheck(dataCtx context.Context) (string, error) { | ||
if c.parentContext() != dataCtx { | ||
log.Error("TemplateContext.DataRaceCheck: parent context mismatch\n%s", log.Stack(2)) | ||
return "", errors.New("parent context mismatch") | ||
} | ||
return "", nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.