Skip to content

Commit d323f5f

Browse files
committed
Merge branch 'main' into lunny/attribute
2 parents d0a2d82 + fac6b87 commit d323f5f

File tree

14 files changed

+77
-57
lines changed

14 files changed

+77
-57
lines changed

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ LEVEL = Info
24572457
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24582458
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24592459
;; Set the maximum number of characters in a mermaid source. (Set to -1 to disable limits)
2460-
;MERMAID_MAX_SOURCE_CHARACTERS = 5000
2460+
;MERMAID_MAX_SOURCE_CHARACTERS = 50000
24612461

24622462
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24632463
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docker/root/etc/s6/openssh/setup

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ if [ -e /data/ssh/ssh_host_ecdsa_cert ]; then
3131
SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa_cert"}
3232
fi
3333

34-
if [ -e /data/ssh/ssh_host_ed25519-cert.pub ]; then
35-
SSH_ED25519_CERT=${SSH_ED25519_CERT:-"/data/ssh/ssh_host_ed25519-cert.pub"}
34+
# In case someone wants to sign the `{keyname}.pub` key by `ssh-keygen -s ca -I identity ...` to
35+
# make use of the ssh-key certificate authority feature (see ssh-keygen CERTIFICATES section),
36+
# the generated key file name is `{keyname}-cert.pub`
37+
if [ -e /data/ssh/ssh_host_ed25519_key-cert.pub ]; then
38+
SSH_ED25519_CERT=${SSH_ED25519_CERT:-"/data/ssh/ssh_host_ed25519_key-cert.pub"}
3639
fi
3740

38-
if [ -e /data/ssh/ssh_host_rsa-cert.pub ]; then
39-
SSH_RSA_CERT=${SSH_RSA_CERT:-"/data/ssh/ssh_host_rsa-cert.pub"}
41+
if [ -e /data/ssh/ssh_host_rsa_key-cert.pub ]; then
42+
SSH_RSA_CERT=${SSH_RSA_CERT:-"/data/ssh/ssh_host_rsa_key-cert.pub"}
4043
fi
4144

42-
if [ -e /data/ssh/ssh_host_ecdsa-cert.pub ]; then
43-
SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa-cert.pub"}
45+
if [ -e /data/ssh/ssh_host_ecdsa_key-cert.pub ]; then
46+
SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa_key-cert.pub"}
4447
fi
4548

4649
if [ -d /etc/ssh ]; then

models/asymkey/gpg_key.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,10 @@ func DeleteGPGKey(ctx context.Context, doer *user_model.User, id int64) (err err
240240

241241
return committer.Commit()
242242
}
243+
244+
func FindGPGKeyWithSubKeys(ctx context.Context, keyID string) ([]*GPGKey, error) {
245+
return db.Find[GPGKey](ctx, FindGPGKeyOptions{
246+
KeyID: keyID,
247+
IncludeSubKeys: true,
248+
})
249+
}

models/user/user.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,29 +1187,28 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
11871187
for _, email := range emailAddresses {
11881188
userIDs.Add(email.UID)
11891189
}
1190-
users, err := GetUsersMapByIDs(ctx, userIDs.Values())
1191-
if err != nil {
1192-
return nil, err
1193-
}
1194-
11951190
results := make(map[string]*User, len(emails))
1196-
for _, email := range emailAddresses {
1197-
user := users[email.UID]
1198-
if user != nil {
1199-
if user.KeepEmailPrivate {
1200-
results[user.LowerName+"@"+setting.Service.NoReplyAddress] = user
1201-
} else {
1202-
results[email.Email] = user
1191+
1192+
if len(userIDs) > 0 {
1193+
users, err := GetUsersMapByIDs(ctx, userIDs.Values())
1194+
if err != nil {
1195+
return nil, err
1196+
}
1197+
1198+
for _, email := range emailAddresses {
1199+
user := users[email.UID]
1200+
if user != nil {
1201+
results[user.GetEmail()] = user
12031202
}
12041203
}
12051204
}
12061205

1207-
users = make(map[int64]*User, len(needCheckUserNames))
1206+
users := make(map[int64]*User, len(needCheckUserNames))
12081207
if err := db.GetEngine(ctx).In("lower_name", needCheckUserNames.Values()).Find(&users); err != nil {
12091208
return nil, err
12101209
}
12111210
for _, user := range users {
1212-
results[user.LowerName+"@"+setting.Service.NoReplyAddress] = user
1211+
results[user.GetPlaceholderEmail()] = user
12131212
}
12141213
return results, nil
12151214
}

modules/cache/context.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ func RemoveContextData(ctx context.Context, tp, key any) {
166166
}
167167

168168
// GetWithContextCache returns the cache value of the given key in the given context.
169-
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error) {
170-
v := GetContextData(ctx, cacheGroupKey, cacheTargetID)
169+
func GetWithContextCache[T, K any](ctx context.Context, groupKey string, targetKey K, f func(context.Context, K) (T, error)) (T, error) {
170+
v := GetContextData(ctx, groupKey, targetKey)
171171
if vv, ok := v.(T); ok {
172172
return vv, nil
173173
}
174-
t, err := f()
174+
t, err := f(ctx, targetKey)
175175
if err != nil {
176176
return t, err
177177
}
178-
SetContextData(ctx, cacheGroupKey, cacheTargetID, t)
178+
SetContextData(ctx, groupKey, targetKey, t)
179179
return t, nil
180180
}

modules/cache/context_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package cache
55

66
import (
7+
"context"
78
"testing"
89
"time"
910

@@ -30,7 +31,7 @@ func TestWithCacheContext(t *testing.T) {
3031
v = GetContextData(ctx, field, "my_config1")
3132
assert.Nil(t, v)
3233

33-
vInt, err := GetWithContextCache(ctx, field, "my_config1", func() (int, error) {
34+
vInt, err := GetWithContextCache(ctx, field, "my_config1", func(context.Context, string) (int, error) {
3435
return 1, nil
3536
})
3637
assert.NoError(t, err)

modules/cachegroup/cachegroup.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package cachegroup
5+
6+
const (
7+
User = "user"
8+
EmailAvatarLink = "email_avatar_link"
9+
UserEmailAddresses = "user_email_addresses"
10+
GPGKeyWithSubKeys = "gpg_key_with_subkeys"
11+
RepoUserPermission = "repo_user_permission"
12+
)

modules/repository/commits.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
user_model "code.gitea.io/gitea/models/user"
1515
"code.gitea.io/gitea/modules/cache"
16+
"code.gitea.io/gitea/modules/cachegroup"
1617
"code.gitea.io/gitea/modules/git"
1718
"code.gitea.io/gitea/modules/log"
1819
"code.gitea.io/gitea/modules/setting"
@@ -131,7 +132,7 @@ func (pc *PushCommits) ToAPIPayloadCommits(ctx context.Context, repo *repo_model
131132
func (pc *PushCommits) AvatarLink(ctx context.Context, email string) string {
132133
size := avatars.DefaultAvatarPixelSize * setting.Avatar.RenderedSizeFactor
133134

134-
v, _ := cache.GetWithContextCache(ctx, "push_commits", email, func() (string, error) {
135+
v, _ := cache.GetWithContextCache(ctx, cachegroup.EmailAvatarLink, email, func(ctx context.Context, email string) (string, error) {
135136
u, err := user_model.GetUserByEmail(ctx, email)
136137
if err != nil {
137138
if !user_model.IsErrUserNotExist(err) {

modules/setting/markup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func loadMarkupFrom(rootCfg ConfigProvider) {
127127
}
128128
}
129129

130-
MermaidMaxSourceCharacters = rootCfg.Section("markup").Key("MERMAID_MAX_SOURCE_CHARACTERS").MustInt(5000)
130+
MermaidMaxSourceCharacters = rootCfg.Section("markup").Key("MERMAID_MAX_SOURCE_CHARACTERS").MustInt(50000)
131131
ExternalMarkupRenderers = make([]*MarkupRenderer, 0, 10)
132132
ExternalSanitizerRules = make([]MarkupSanitizerRule, 0, 10)
133133

routers/private/hook_post_receive.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
repo_model "code.gitea.io/gitea/models/repo"
1515
user_model "code.gitea.io/gitea/models/user"
1616
"code.gitea.io/gitea/modules/cache"
17+
"code.gitea.io/gitea/modules/cachegroup"
1718
"code.gitea.io/gitea/modules/git"
1819
"code.gitea.io/gitea/modules/gitrepo"
1920
"code.gitea.io/gitea/modules/log"
@@ -326,9 +327,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
326327
}
327328

328329
func loadContextCacheUser(ctx context.Context, id int64) (*user_model.User, error) {
329-
return cache.GetWithContextCache(ctx, "hook_post_receive_user", id, func() (*user_model.User, error) {
330-
return user_model.GetUserByID(ctx, id)
331-
})
330+
return cache.GetWithContextCache(ctx, cachegroup.User, id, user_model.GetUserByID)
332331
}
333332

334333
// handlePullRequestMerging handle pull request merging, a pull request action should push at least 1 commit

0 commit comments

Comments
 (0)