Skip to content

Commit cbea9db

Browse files
committed
Merge branch 'main' of https://github.com/go-gitea/gitea into ephemeral-runners
2 parents c87aa86 + 38ccc8e commit cbea9db

File tree

24 files changed

+313
-157
lines changed

24 files changed

+313
-157
lines changed

.github/workflows/release-tag-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ jobs:
8888
# 1.2
8989
# 1.2.3
9090
tags: |
91+
type=semver,pattern={{version}}
9192
type=semver,pattern={{major}}
9293
type=semver,pattern={{major}}.{{minor}}
93-
type=semver,pattern={{version}}
9494
- name: Login to Docker Hub
9595
uses: docker/login-action@v3
9696
with:
@@ -126,9 +126,9 @@ jobs:
126126
# 1.2
127127
# 1.2.3
128128
tags: |
129+
type=semver,pattern={{version}}
129130
type=semver,pattern={{major}}
130131
type=semver,pattern={{major}}.{{minor}}
131-
type=semver,pattern={{version}}
132132
- name: Login to Docker Hub
133133
uses: docker/login-action@v3
134134
with:

cmd/web_acme.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ func runACME(listenAddr string, m http.Handler) error {
5454
altTLSALPNPort = p
5555
}
5656

57-
// FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
58-
// Ideally it should migrate to AppDataPath write to "AppDataPath/https"
59-
certmagic.Default.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
60-
magic := certmagic.NewDefault()
6157
// Try to use private CA root if provided, otherwise defaults to system's trust
6258
var certPool *x509.CertPool
6359
if setting.AcmeCARoot != "" {
@@ -67,7 +63,13 @@ func runACME(listenAddr string, m http.Handler) error {
6763
log.Warn("Failed to parse CA Root certificate, using default CA trust: %v", err)
6864
}
6965
}
70-
myACME := certmagic.NewACMEIssuer(magic, certmagic.ACMEIssuer{
66+
// FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
67+
// Ideally it should migrate to AppDataPath write to "AppDataPath/https"
68+
// And one more thing, no idea why we should set the global default variables here
69+
// But it seems that the current ACME code needs these global variables to make renew work.
70+
// Otherwise, "renew" will use incorrect storage path
71+
certmagic.Default.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
72+
certmagic.DefaultACME = certmagic.ACMEIssuer{
7173
CA: setting.AcmeURL,
7274
TrustedRoots: certPool,
7375
Email: setting.AcmeEmail,
@@ -77,8 +79,10 @@ func runACME(listenAddr string, m http.Handler) error {
7779
ListenHost: setting.HTTPAddr,
7880
AltTLSALPNPort: altTLSALPNPort,
7981
AltHTTPPort: altHTTPPort,
80-
})
82+
}
8183

84+
magic := certmagic.NewDefault()
85+
myACME := certmagic.NewACMEIssuer(magic, certmagic.DefaultACME)
8286
magic.Issuers = []certmagic.Issuer{myACME}
8387

8488
// this obtains certificates or renews them if necessary

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ require (
117117
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
118118
github.com/yuin/goldmark-meta v1.1.0
119119
gitlab.com/gitlab-org/api/client-go v0.123.0
120-
golang.org/x/crypto v0.33.0
120+
golang.org/x/crypto v0.35.0
121121
golang.org/x/image v0.24.0
122122
golang.org/x/net v0.35.0
123-
golang.org/x/oauth2 v0.26.0
123+
golang.org/x/oauth2 v0.27.0
124124
golang.org/x/sync v0.11.0
125125
golang.org/x/sys v0.30.0
126126
golang.org/x/text v0.22.0

go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,9 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
831831
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
832832
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
833833
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
834-
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
835834
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
835+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
836+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
836837
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4=
837838
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
838839
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
@@ -868,8 +869,8 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
868869
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
869870
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
870871
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
871-
golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
872-
golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
872+
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
873+
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
873874
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
874875
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
875876
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

models/activities/action.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,24 @@ func ActivityReadable(user, doer *user_model.User) bool {
454454
doer != nil && (doer.IsAdmin || user.ID == doer.ID)
455455
}
456456

457+
func FeedDateCond(opts GetFeedsOptions) builder.Cond {
458+
cond := builder.NewCond()
459+
if opts.Date == "" {
460+
return cond
461+
}
462+
463+
dateLow, err := time.ParseInLocation("2006-01-02", opts.Date, setting.DefaultUILocation)
464+
if err != nil {
465+
log.Warn("Unable to parse %s, filter not applied: %v", opts.Date, err)
466+
} else {
467+
dateHigh := dateLow.Add(86399000000000) // 23h59m59s
468+
469+
cond = cond.And(builder.Gte{"`action`.created_unix": dateLow.Unix()})
470+
cond = cond.And(builder.Lte{"`action`.created_unix": dateHigh.Unix()})
471+
}
472+
return cond
473+
}
474+
457475
func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.Cond, error) {
458476
cond := builder.NewCond()
459477

@@ -534,17 +552,7 @@ func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.
534552
cond = cond.And(builder.Eq{"is_deleted": false})
535553
}
536554

537-
if opts.Date != "" {
538-
dateLow, err := time.ParseInLocation("2006-01-02", opts.Date, setting.DefaultUILocation)
539-
if err != nil {
540-
log.Warn("Unable to parse %s, filter not applied: %v", opts.Date, err)
541-
} else {
542-
dateHigh := dateLow.Add(86399000000000) // 23h59m59s
543-
544-
cond = cond.And(builder.Gte{"`action`.created_unix": dateLow.Unix()})
545-
cond = cond.And(builder.Lte{"`action`.created_unix": dateHigh.Unix()})
546-
}
547-
}
555+
cond = cond.And(FeedDateCond(opts))
548556

549557
return cond, nil
550558
}

models/activities/action_list.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,31 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
208208
return nil, 0, fmt.Errorf("need at least one of these filters: RequestedUser, RequestedTeam, RequestedRepo")
209209
}
210210

211-
cond, err := ActivityQueryCondition(ctx, opts)
212-
if err != nil {
213-
return nil, 0, err
211+
var err error
212+
var cond builder.Cond
213+
// if the actor is the requested user or is an administrator, we can skip the ActivityQueryCondition
214+
if opts.Actor != nil && opts.RequestedUser != nil && (opts.Actor.IsAdmin || opts.Actor.ID == opts.RequestedUser.ID) {
215+
cond = builder.Eq{
216+
"user_id": opts.RequestedUser.ID,
217+
}.And(
218+
FeedDateCond(opts),
219+
)
220+
221+
if !opts.IncludeDeleted {
222+
cond = cond.And(builder.Eq{"is_deleted": false})
223+
}
224+
225+
if !opts.IncludePrivate {
226+
cond = cond.And(builder.Eq{"is_private": false})
227+
}
228+
if opts.OnlyPerformedBy {
229+
cond = cond.And(builder.Eq{"act_user_id": opts.RequestedUser.ID})
230+
}
231+
} else {
232+
cond, err = ActivityQueryCondition(ctx, opts)
233+
if err != nil {
234+
return nil, 0, err
235+
}
214236
}
215237

216238
actions := make([]*Action, 0, opts.PageSize)

models/organization/org_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func GetUserOrgsList(ctx context.Context, user *user_model.User) ([]*MinimalOrg,
124124
if err := db.GetEngine(ctx).Select(columnsStr).
125125
Table("user").
126126
Where(builder.In("`user`.`id`", queryUserOrgIDs(user.ID, true))).
127+
OrderBy("`user`.lower_name ASC").
127128
Find(&orgs); err != nil {
128129
return nil, err
129130
}

models/repo/user_repo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package repo
55

66
import (
77
"context"
8+
"strings"
89

910
"code.gitea.io/gitea/models/db"
1011
"code.gitea.io/gitea/models/perm"
@@ -149,9 +150,9 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us
149150
// If isShowFullName is set to true, also include full name prefix search
150151
func GetIssuePostersWithSearch(ctx context.Context, repo *Repository, isPull bool, search string, isShowFullName bool) ([]*user_model.User, error) {
151152
users := make([]*user_model.User, 0, 30)
152-
var prefixCond builder.Cond = builder.Like{"name", search + "%"}
153+
var prefixCond builder.Cond = builder.Like{"lower_name", strings.ToLower(search) + "%"}
153154
if isShowFullName {
154-
prefixCond = prefixCond.Or(builder.Like{"full_name", "%" + search + "%"})
155+
prefixCond = prefixCond.Or(db.BuildCaseInsensitiveLike("full_name", "%"+search+"%"))
155156
}
156157

157158
cond := builder.In("`user`.id",

models/repo/user_repo_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
user_model "code.gitea.io/gitea/models/user"
1313

1414
"github.com/stretchr/testify/assert"
15+
"github.com/stretchr/testify/require"
1516
)
1617

1718
func TestRepoAssignees(t *testing.T) {
@@ -38,3 +39,19 @@ func TestRepoAssignees(t *testing.T) {
3839
assert.NotContains(t, []int64{users[0].ID, users[1].ID, users[2].ID}, 15)
3940
}
4041
}
42+
43+
func TestGetIssuePostersWithSearch(t *testing.T) {
44+
assert.NoError(t, unittest.PrepareTestDatabase())
45+
46+
repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
47+
48+
users, err := repo_model.GetIssuePostersWithSearch(db.DefaultContext, repo2, false, "USER", false /* full name */)
49+
require.NoError(t, err)
50+
require.Len(t, users, 1)
51+
assert.Equal(t, "user2", users[0].Name)
52+
53+
users, err = repo_model.GetIssuePostersWithSearch(db.DefaultContext, repo2, false, "TW%O", true /* full name */)
54+
require.NoError(t, err)
55+
require.Len(t, users, 1)
56+
assert.Equal(t, "user2", users[0].Name)
57+
}

modules/setting/server.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,24 @@ func loadServerFrom(rootCfg ConfigProvider) {
169169
HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
170170
HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
171171

172+
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
173+
// if these are removed, the warning will not be shown
174+
if sec.HasKey("ENABLE_ACME") {
175+
EnableAcme = sec.Key("ENABLE_ACME").MustBool(false)
176+
} else {
177+
deprecatedSetting(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", "v1.19.0")
178+
EnableAcme = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
179+
}
180+
172181
Protocol = HTTP
173182
protocolCfg := sec.Key("PROTOCOL").String()
183+
if protocolCfg != "https" && EnableAcme {
184+
log.Fatal("ACME could only be used with HTTPS protocol")
185+
}
186+
174187
switch protocolCfg {
175188
case "https":
176189
Protocol = HTTPS
177-
178-
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
179-
// if these are removed, the warning will not be shown
180-
if sec.HasKey("ENABLE_ACME") {
181-
EnableAcme = sec.Key("ENABLE_ACME").MustBool(false)
182-
} else {
183-
deprecatedSetting(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", "v1.19.0")
184-
EnableAcme = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
185-
}
186190
if EnableAcme {
187191
AcmeURL = sec.Key("ACME_URL").MustString("")
188192
AcmeCARoot = sec.Key("ACME_CA_ROOT").MustString("")
@@ -210,6 +214,9 @@ func loadServerFrom(rootCfg ConfigProvider) {
210214
deprecatedSetting(rootCfg, "server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL", "v1.19.0")
211215
AcmeEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
212216
}
217+
if AcmeEmail == "" {
218+
log.Fatal("ACME Email is not set (ACME_EMAIL).")
219+
}
213220
} else {
214221
CertFile = sec.Key("CERT_FILE").String()
215222
KeyFile = sec.Key("KEY_FILE").String()

0 commit comments

Comments
 (0)