2019-06-08 01:59:29 +05:30
|
|
|
{{template "base/head" .}}
|
2023-02-02 04:26:10 +05:30
|
|
|
<div role="main" aria-label="{{.Title}}" class="page-content repository diff">
|
2019-06-08 01:59:29 +05:30
|
|
|
{{template "repo/header" .}}
|
2023-02-17 00:55:00 +05:30
|
|
|
<div class="ui container fluid padded">
|
2020-02-28 00:50:55 +05:30
|
|
|
{{$class := ""}}
|
|
|
|
{{if .Commit.Signature}}
|
|
|
|
{{$class = (printf "%s%s" $class " isSigned")}}
|
|
|
|
{{if .Verification.Verified}}
|
|
|
|
{{if eq .Verification.TrustStatus "trusted"}}
|
|
|
|
{{$class = (printf "%s%s" $class " isVerified")}}
|
|
|
|
{{else if eq .Verification.TrustStatus "untrusted"}}
|
|
|
|
{{$class = (printf "%s%s" $class " isVerifiedUntrusted")}}
|
|
|
|
{{else}}
|
|
|
|
{{$class = (printf "%s%s" $class " isVerifiedUnmatched")}}
|
|
|
|
{{end}}
|
|
|
|
{{else if .Verification.Warning}}
|
|
|
|
{{$class = (printf "%s%s" $class " isWarning")}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
2023-02-21 05:46:56 +05:30
|
|
|
<div class="ui top attached header clearing segment gt-relative commit-header {{$class}}">
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="gt-df gt-mb-4 gt-fw">
|
|
|
|
<h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}</h3>
|
2022-02-10 01:58:55 +05:30
|
|
|
{{if not $.PageIsWiki}}
|
|
|
|
<div class="ui">
|
2022-05-20 03:38:08 +05:30
|
|
|
<a class="ui primary tiny button" href="{{.SourcePath}}">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{.locale.Tr "repo.diff.browse_source"}}
|
2022-02-10 01:58:55 +05:30
|
|
|
</a>
|
|
|
|
{{if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}{{- /* */ -}}
|
2022-12-08 18:44:09 +05:30
|
|
|
<div class="ui primary tiny floating dropdown icon button">{{.locale.Tr "repo.commit.operations"}}
|
2022-12-02 09:09:19 +05:30
|
|
|
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
2022-02-10 01:58:55 +05:30
|
|
|
<div class="menu">
|
2022-12-08 18:44:09 +05:30
|
|
|
<div class="ui header">{{.locale.Tr "repo.commit.operations"}}</div>
|
2022-02-10 01:58:55 +05:30
|
|
|
<div class="divider"></div>
|
|
|
|
<div class="item show-create-branch-modal"
|
2022-06-28 02:28:46 +05:30
|
|
|
data-content="{{$.locale.Tr "repo.branch.new_branch_from" (.CommitID)}}"
|
2022-02-10 01:58:55 +05:30
|
|
|
data-branch-from="{{ShortSha .CommitID}}"
|
|
|
|
data-branch-from-urlcomponent="{{.CommitID}}"
|
|
|
|
data-modal="#create-branch-modal">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{.locale.Tr "repo.branch.create_branch_operation"}}
|
2022-02-10 01:58:55 +05:30
|
|
|
</div>
|
|
|
|
<div class="item show-create-branch-modal"
|
2022-06-28 02:28:46 +05:30
|
|
|
data-content="{{$.locale.Tr "repo.branch.new_branch_from" (.CommitID)}}"
|
2022-02-10 01:58:55 +05:30
|
|
|
data-branch-from="{{ShortSha .CommitID}}"
|
|
|
|
data-branch-from-urlcomponent="{{.CommitID}}"
|
|
|
|
data-modal="#create-tag-modal"
|
|
|
|
data-modal-from-span="#modal-create-tag-from-span"
|
|
|
|
data-modal-form="#create-tag-form">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{.locale.Tr "repo.tag.create_tag_operation"}}
|
2022-02-10 01:58:55 +05:30
|
|
|
</div>
|
|
|
|
<div class="item show-modal revert-button"
|
|
|
|
data-modal="#cherry-pick-modal"
|
|
|
|
data-modal-cherry-pick-type="revert"
|
2022-06-28 02:28:46 +05:30
|
|
|
data-modal-cherry-pick-header="{{$.locale.Tr "repo.commit.revert-header" (ShortSha .CommitID)}}"
|
|
|
|
data-modal-cherry-pick-content="{{$.locale.Tr "repo.commit.revert-content"}}"
|
|
|
|
data-modal-cherry-pick-submit="{{.locale.Tr "repo.commit.revert"}}">{{.locale.Tr "repo.commit.revert"}}</a></div>
|
2022-02-10 01:58:55 +05:30
|
|
|
<div class="item cherry-pick-button show-modal"
|
|
|
|
data-modal="#cherry-pick-modal"
|
|
|
|
data-modal-cherry-pick-type="cherry-pick"
|
2022-06-28 02:28:46 +05:30
|
|
|
data-modal-cherry-pick-header="{{$.locale.Tr "repo.commit.cherry-pick-header" (ShortSha .CommitID)}}"
|
|
|
|
data-modal-cherry-pick-content="{{$.locale.Tr "repo.commit.cherry-pick-content"}}"
|
|
|
|
data-modal-cherry-pick-submit="{{.locale.Tr "repo.commit.cherry-pick"}}">{{.locale.Tr "repo.commit.cherry-pick"}}</a></div>
|
2022-02-10 01:58:55 +05:30
|
|
|
<div class="ui basic modal" id="cherry-pick-modal">
|
|
|
|
<div class="ui icon header">
|
|
|
|
<span id="cherry-pick-header"></span>
|
|
|
|
</div>
|
|
|
|
<div class="content center">
|
|
|
|
<p id="cherry-pick-content" class="branch-dropdown"></p>
|
|
|
|
{{template "repo/branch_dropdown" dict "root" .
|
|
|
|
"noTag" "true" "canCreateBranch" "false"
|
|
|
|
"branchForm" "branch-dropdown-form"
|
|
|
|
"branchURLPrefix" (printf "%s/_cherrypick/%s/" $.RepoLink .CommitID) "branchURLSuffix" ""
|
|
|
|
"setAction" "true" "submitForm" "true"}}
|
|
|
|
<form method="GET" action="{{$.RepoLink}}/_cherrypick/{{.CommitID}}/{{if $.BranchName}}{{PathEscapeSegments $.BranchName}}{{else}}{{PathEscapeSegments $.Repository.DefaultBranch}}{{end}}" id="branch-dropdown-form">
|
|
|
|
<input type="hidden" name="ref" value="{{if $.BranchName}}{{$.BranchName}}{{else}}{{$.Repository.DefaultBranch}}{{end}}">
|
|
|
|
<input type="hidden" name="refType" value="branch">
|
|
|
|
<input type="hidden" id="cherry-pick-type" name="cherry-pick-type"><br/>
|
|
|
|
<button type="submit" id="cherry-pick-submit" class="ui green button"></button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="ui small modal" id="create-branch-modal">
|
|
|
|
<div class="header">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{.locale.Tr "repo.branch.new_branch"}}
|
2022-02-10 01:58:55 +05:30
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<form class="ui form" id="create-branch-form" action="" data-base-action="{{.RepoLink}}/branches/_new/commit/" method="post">
|
|
|
|
{{.CsrfTokenHtml}}
|
|
|
|
<div class="field">
|
|
|
|
<label>
|
2022-08-26 03:25:52 +05:30
|
|
|
{{.locale.Tr "repo.branch.new_branch_from" "<span class=\"text\" id=\"modal-create-branch-from-span\"></span>" | Safe}}
|
2022-02-10 01:58:55 +05:30
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="required field">
|
2022-06-28 02:28:46 +05:30
|
|
|
<label for="new_branch_name">{{.locale.Tr "repo.branch.name"}}</label>
|
2022-02-10 01:58:55 +05:30
|
|
|
<input id="new_branch_name" name="new_branch_name" required>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="text right actions">
|
2022-06-28 02:28:46 +05:30
|
|
|
<div class="ui cancel button">{{.locale.Tr "settings.cancel"}}</div>
|
|
|
|
<button class="ui green button">{{.locale.Tr "repo.branch.confirm_create_branch"}}</button>
|
2022-02-10 01:58:55 +05:30
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="ui small modal" id="create-tag-modal">
|
|
|
|
<div class="header">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{.locale.Tr "repo.tag.create_tag_operation"}}
|
2022-02-10 01:58:55 +05:30
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<form class="ui form" id="create-tag-form" action="" data-base-action="{{.RepoLink}}/branches/_new/commit/" method="post">
|
|
|
|
{{.CsrfTokenHtml}}
|
|
|
|
<input type="hidden" name="create_tag" value="true">
|
|
|
|
<div class="field">
|
|
|
|
<label>
|
2022-08-26 03:25:52 +05:30
|
|
|
{{.locale.Tr "repo.tag.create_tag_from" "<span class=\"text\" id=\"modal-create-tag-from-span\"></span>" | Safe}}
|
2022-02-10 01:58:55 +05:30
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div class="required field">
|
2022-06-28 02:28:46 +05:30
|
|
|
<label for="new_branch_name">{{.locale.Tr "repo.release.tag_name"}}</label>
|
2022-02-10 01:58:55 +05:30
|
|
|
<input id="new_branch_name" name="new_branch_name" required>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="text right actions">
|
2022-06-28 02:28:46 +05:30
|
|
|
<div class="ui cancel button">{{.locale.Tr "settings.cancel"}}</div>
|
|
|
|
<button class="ui green button">{{.locale.Tr "repo.tag.confirm_create_tag"}}</button>
|
2022-02-10 01:58:55 +05:30
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2019-06-08 01:59:29 +05:30
|
|
|
{{if IsMultilineCommitMessage .Commit.Message}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<pre class="commit-body gt-mt-0">{{RenderCommitBody $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</pre>
|
2019-06-08 01:59:29 +05:30
|
|
|
{{end}}
|
2020-05-24 01:19:48 +05:30
|
|
|
{{if .BranchName}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="text grey gt-mr-3">{{svg "octicon-git-branch" 16 "gt-mr-2"}}{{.BranchName}}</span>
|
2020-05-24 01:19:48 +05:30
|
|
|
{{end}}
|
2020-06-12 01:12:55 +05:30
|
|
|
{{if .TagName}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="text grey gt-mr-3">{{svg "octicon-tag" 16 "gt-mr-2"}}{{.TagName}}</span>
|
2020-06-12 01:12:55 +05:30
|
|
|
{{end}}
|
2019-06-08 01:59:29 +05:30
|
|
|
</div>
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="ui attached segment gt-df gt-ac gt-sb gt-py-2 commit-header-row gt-fw {{$class}}">
|
|
|
|
<div class="gt-df gt-ac author">
|
2019-06-08 01:59:29 +05:30
|
|
|
{{if .Author}}
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 19:07:34 +05:30
|
|
|
{{avatar $.Context .Author 28 "gt-mr-3"}}
|
2020-12-04 00:16:11 +05:30
|
|
|
{{if .Author.FullName}}
|
|
|
|
<a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a>
|
|
|
|
{{else}}
|
|
|
|
<a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a>
|
|
|
|
{{end}}
|
2019-06-08 01:59:29 +05:30
|
|
|
{{else}}
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 19:07:34 +05:30
|
|
|
{{avatarByEmail $.Context .Commit.Author.Email .Commit.Author.Email 28 "gt-mr-3"}}
|
2019-06-08 01:59:29 +05:30
|
|
|
<strong>{{.Commit.Author.Name}}</strong>
|
|
|
|
{{end}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="text grey gt-ml-3" id="authored-time">{{TimeSince .Commit.Author.When $.locale}}</span>
|
2019-10-16 19:12:42 +05:30
|
|
|
{{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="text grey gt-mx-3">{{.locale.Tr "repo.diff.committed_by"}}</span>
|
2021-12-01 05:10:17 +05:30
|
|
|
{{if ne .Verification.CommittingUser.ID 0}}
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 19:07:34 +05:30
|
|
|
{{avatar $.Context .Verification.CommittingUser 28 "gt-mx-3"}}
|
2021-12-01 05:10:17 +05:30
|
|
|
<a href="{{.Verification.CommittingUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a>
|
|
|
|
{{else}}
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 19:07:34 +05:30
|
|
|
{{avatarByEmail $.Context .Commit.Committer.Email .Commit.Committer.Name 28 "gt-mr-3"}}
|
2021-12-01 05:10:17 +05:30
|
|
|
<strong>{{.Commit.Committer.Name}}</strong>
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="ui horizontal list gt-df gt-ac">
|
2021-12-01 05:10:17 +05:30
|
|
|
{{if .Parents}}
|
|
|
|
<div class="item">
|
2022-06-28 02:28:46 +05:30
|
|
|
<span>{{.locale.Tr "repo.diff.parent"}}</span>
|
2021-12-01 05:10:17 +05:30
|
|
|
{{range .Parents}}
|
|
|
|
{{if $.PageIsWiki}}
|
2022-05-20 03:38:08 +05:30
|
|
|
<a class="ui primary sha label" href="{{$.RepoLink}}/wiki/commit/{{PathEscape .}}">{{ShortSha .}}</a>
|
2021-12-01 05:10:17 +05:30
|
|
|
{{else}}
|
2022-05-20 03:38:08 +05:30
|
|
|
<a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{PathEscape .}}">{{ShortSha .}}</a>
|
2021-12-01 05:10:17 +05:30
|
|
|
{{end}}
|
2020-06-03 08:10:08 +05:30
|
|
|
{{end}}
|
|
|
|
</div>
|
2019-10-16 19:12:42 +05:30
|
|
|
{{end}}
|
2022-05-16 22:15:12 +05:30
|
|
|
<div class="item">
|
2022-06-28 02:28:46 +05:30
|
|
|
<span>{{.locale.Tr "repo.diff.commit"}}</span>
|
2022-05-20 03:38:08 +05:30
|
|
|
<span class="ui primary sha label">{{ShortSha .CommitID}}</span>
|
2022-05-16 22:15:12 +05:30
|
|
|
</div>
|
2019-06-08 01:59:29 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{if .Commit.Signature}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="ui bottom attached message gt-tl gt-df gt-ac gt-sb commit-header-row gt-fw {{$class}}">
|
|
|
|
<div class="gt-df gt-ac">
|
2021-12-01 05:10:17 +05:30
|
|
|
{{if .Verification.Verified}}
|
|
|
|
{{if ne .Verification.SigningUser.ID 0}}
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "gitea-lock" 16 "gt-mr-3"}}
|
2021-12-01 05:10:17 +05:30
|
|
|
{{if eq .Verification.TrustStatus "trusted"}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by"}}:</span>
|
2021-12-01 05:10:17 +05:30
|
|
|
{{else if eq .Verification.TrustStatus "untrusted"}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by_untrusted_user"}}:</span>
|
2021-12-01 05:10:17 +05:30
|
|
|
{{else}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span>
|
2021-12-01 05:10:17 +05:30
|
|
|
{{end}}
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 19:07:34 +05:30
|
|
|
{{avatar $.Context .Verification.SigningUser 28 "gt-mr-3"}}
|
2022-02-21 01:20:11 +05:30
|
|
|
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a>
|
2020-02-28 00:50:55 +05:30
|
|
|
{{else}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span title="{{.locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog" 16 "gt-mr-3"}}</span>
|
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by"}}:</span>
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 19:07:34 +05:30
|
|
|
{{avatarByEmail $.Context .Verification.SigningEmail "" 28}}
|
2022-02-21 01:20:11 +05:30
|
|
|
<strong>{{.Verification.SigningUser.GetDisplayName}}</strong>
|
2020-02-28 00:50:55 +05:30
|
|
|
{{end}}
|
2019-10-16 19:12:42 +05:30
|
|
|
{{else}}
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "gitea-unlock" 16 "gt-mr-3"}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<span class="ui text">{{.locale.Tr .Verification.Reason}}</span>
|
2019-10-16 19:12:42 +05:30
|
|
|
{{end}}
|
2021-12-01 05:10:17 +05:30
|
|
|
</div>
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="gt-df gt-ac">
|
2021-12-01 05:10:17 +05:30
|
|
|
{{if .Verification.Verified}}
|
|
|
|
{{if ne .Verification.SigningUser.ID 0}}
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "octicon-shield-check" 16 "gt-mr-3"}}
|
2021-12-19 11:07:18 +05:30
|
|
|
{{if .Verification.SigningSSHKey}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
|
2021-12-19 11:07:18 +05:30
|
|
|
{{.Verification.SigningSSHKey.Fingerprint}}
|
|
|
|
{{else}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.gpg_key_id"}}:</span>
|
2022-08-21 12:20:15 +05:30
|
|
|
{{.Verification.SigningKey.PaddedKeyID}}
|
2021-12-19 11:07:18 +05:30
|
|
|
{{end}}
|
2021-12-01 05:10:17 +05:30
|
|
|
{{else}}
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "octicon-shield-lock" 16 "gt-mr-3"}}
|
2021-12-19 11:07:18 +05:30
|
|
|
{{if .Verification.SigningSSHKey}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3 tooltip" data-content="{{.locale.Tr "gpg.default_key"}}">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
|
2021-12-19 11:07:18 +05:30
|
|
|
{{.Verification.SigningSSHKey.Fingerprint}}
|
|
|
|
{{else}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3 tooltip" data-content="{{.locale.Tr "gpg.default_key"}}">{{.locale.Tr "repo.commits.gpg_key_id"}}:</span>
|
2022-08-21 12:20:15 +05:30
|
|
|
{{.Verification.SigningKey.PaddedKeyID}}
|
2021-12-19 11:07:18 +05:30
|
|
|
{{end}}
|
2021-12-01 05:10:17 +05:30
|
|
|
{{end}}
|
|
|
|
{{else if .Verification.Warning}}
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "octicon-shield" 16 "gt-mr-3"}}
|
2021-12-19 11:07:18 +05:30
|
|
|
{{if .Verification.SigningSSHKey}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
|
2021-12-19 11:07:18 +05:30
|
|
|
{{.Verification.SigningSSHKey.Fingerprint}}
|
|
|
|
{{else}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.gpg_key_id"}}:</span>
|
2022-08-21 12:20:15 +05:30
|
|
|
{{.Verification.SigningKey.PaddedKeyID}}
|
2021-12-19 11:07:18 +05:30
|
|
|
{{end}}
|
2021-12-01 05:10:17 +05:30
|
|
|
{{else}}
|
|
|
|
{{if .Verification.SigningKey}}
|
|
|
|
{{if ne .Verification.SigningKey.KeyID ""}}
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "octicon-shield" 16 "gt-mr-3"}}
|
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.gpg_key_id"}}:</span>
|
2022-08-21 12:20:15 +05:30
|
|
|
{{.Verification.SigningKey.PaddedKeyID}}
|
2021-12-01 05:10:17 +05:30
|
|
|
{{end}}
|
2021-04-11 09:16:37 +05:30
|
|
|
{{end}}
|
2021-12-19 11:07:18 +05:30
|
|
|
{{if .Verification.SigningSSHKey}}
|
|
|
|
{{if ne .Verification.SigningSSHKey.Fingerprint ""}}
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "octicon-shield" 16 "gt-mr-3"}}
|
|
|
|
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
|
2021-12-19 11:07:18 +05:30
|
|
|
{{.Verification.SigningSSHKey.Fingerprint}}
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
2021-04-11 09:16:37 +05:30
|
|
|
{{end}}
|
2021-12-01 05:10:17 +05:30
|
|
|
</div>
|
2020-02-28 00:50:55 +05:30
|
|
|
</div>
|
2019-06-08 01:59:29 +05:30
|
|
|
{{end}}
|
|
|
|
{{if .Note}}
|
2021-12-01 05:10:17 +05:30
|
|
|
<div class="ui top attached header segment git-notes">
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "octicon-note" 16 "gt-mr-3"}}
|
2022-06-28 02:28:46 +05:30
|
|
|
{{.locale.Tr "repo.diff.git-notes"}}:
|
2019-06-08 01:59:29 +05:30
|
|
|
{{if .NoteAuthor}}
|
|
|
|
<a href="{{.NoteAuthor.HomeLink}}">
|
|
|
|
{{if .NoteAuthor.FullName}}
|
2021-04-11 09:16:37 +05:30
|
|
|
<strong>{{.NoteAuthor.FullName}}</strong>
|
2019-06-08 01:59:29 +05:30
|
|
|
{{else}}
|
2021-04-11 09:16:37 +05:30
|
|
|
<strong>{{.NoteCommit.Author.Name}}</strong>
|
2019-06-08 01:59:29 +05:30
|
|
|
{{end}}
|
|
|
|
</a>
|
|
|
|
{{else}}
|
|
|
|
<strong>{{.NoteCommit.Author.Name}}</strong>
|
|
|
|
{{end}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<span class="text grey" id="note-authored-time">{{TimeSince .NoteCommit.Author.When $.locale}}</span>
|
2019-06-08 01:59:29 +05:30
|
|
|
</div>
|
|
|
|
<div class="ui bottom attached info segment git-notes">
|
2022-01-20 04:56:57 +05:30
|
|
|
<pre class="commit-body">{{RenderNote $.Context .Note $.RepoLink $.Repository.ComposeMetas}}</pre>
|
2019-06-08 01:59:29 +05:30
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
{{template "repo/diff/box" .}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{template "base/footer" .}}
|