Skip to content

Commit edb4486

Browse files
committed
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/ChristopherHX/34341
2 parents 452f58b + 3f7dbbd commit edb4486

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+350
-334
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.24-alpine3.21 AS build-env
2+
FROM docker.io/library/golang:1.24-alpine3.22 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -41,7 +41,7 @@ RUN chmod 755 /tmp/local/usr/bin/entrypoint \
4141
/go/src/code.gitea.io/gitea/environment-to-ini
4242
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4343

44-
FROM docker.io/library/alpine:3.21
44+
FROM docker.io/library/alpine:3.22
4545
LABEL maintainer="[email protected]"
4646

4747
EXPOSE 22 3000

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.24-alpine3.21 AS build-env
2+
FROM docker.io/library/golang:1.24-alpine3.22 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -39,7 +39,7 @@ RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
3939
/go/src/code.gitea.io/gitea/environment-to-ini
4040
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4141

42-
FROM docker.io/library/alpine:3.21
42+
FROM docker.io/library/alpine:3.22
4343
LABEL maintainer="[email protected]"
4444

4545
EXPOSE 2222 3000

cmd/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
107107

108108
log.Trace("Synchronizing repository releases (this may take a while)")
109109
for page := 1; ; page++ {
110-
repos, count, err := repo_model.SearchRepositoryByName(ctx, &repo_model.SearchRepoOptions{
110+
repos, count, err := repo_model.SearchRepositoryByName(ctx, repo_model.SearchRepoOptions{
111111
ListOptions: db.ListOptions{
112112
PageSize: repo_model.RepositoryListDefaultPageSize,
113113
Page: page,

cmd/admin_auth_ldap_test.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
"code.gitea.io/gitea/models/auth"
11+
"code.gitea.io/gitea/modules/test"
1112
"code.gitea.io/gitea/services/auth/source/ldap"
1213

1314
"github.com/stretchr/testify/assert"
@@ -16,9 +17,7 @@ import (
1617

1718
func TestAddLdapBindDn(t *testing.T) {
1819
// Mock cli functions to do not exit on error
19-
osExiter := cli.OsExiter
20-
defer func() { cli.OsExiter = osExiter }()
21-
cli.OsExiter = func(code int) {}
20+
defer test.MockVariableValue(&cli.OsExiter, func(code int) {})()
2221

2322
// Test cases
2423
cases := []struct {
@@ -256,9 +255,7 @@ func TestAddLdapBindDn(t *testing.T) {
256255

257256
func TestAddLdapSimpleAuth(t *testing.T) {
258257
// Mock cli functions to do not exit on error
259-
osExiter := cli.OsExiter
260-
defer func() { cli.OsExiter = osExiter }()
261-
cli.OsExiter = func(code int) {}
258+
defer test.MockVariableValue(&cli.OsExiter, func(code int) {})()
262259

263260
// Test cases
264261
cases := []struct {
@@ -487,9 +484,7 @@ func TestAddLdapSimpleAuth(t *testing.T) {
487484

488485
func TestUpdateLdapBindDn(t *testing.T) {
489486
// Mock cli functions to do not exit on error
490-
osExiter := cli.OsExiter
491-
defer func() { cli.OsExiter = osExiter }()
492-
cli.OsExiter = func(code int) {}
487+
defer test.MockVariableValue(&cli.OsExiter, func(code int) {})()
493488

494489
// Test cases
495490
cases := []struct {
@@ -964,9 +959,7 @@ func TestUpdateLdapBindDn(t *testing.T) {
964959

965960
func TestUpdateLdapSimpleAuth(t *testing.T) {
966961
// Mock cli functions to do not exit on error
967-
osExiter := cli.OsExiter
968-
defer func() { cli.OsExiter = osExiter }()
969-
cli.OsExiter = func(code int) {}
962+
defer test.MockVariableValue(&cli.OsExiter, func(code int) {})()
970963

971964
// Test cases
972965
cases := []struct {

cmd/web_graceful.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ func NoHTTPRedirector() {
2323
graceful.GetManager().InformCleanup()
2424
}
2525

26-
// NoMainListener tells our cleanup routine that we will not be using a possibly provided listener
27-
// for our main HTTP/HTTPS service
28-
func NoMainListener() {
29-
graceful.GetManager().InformCleanup()
30-
}
31-
3226
// NoInstallListener tells our cleanup routine that we will not be using a possibly provided listener
3327
// for our install HTTP/HTTPS service
3428
func NoInstallListener() {

models/activities/user_heatmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organi
6666
Select(groupBy+" AS timestamp, count(user_id) as contributions").
6767
Table("action").
6868
Where(cond).
69-
And("created_unix > ?", timeutil.TimeStampNow()-31536000).
69+
And("created_unix > ?", timeutil.TimeStampNow()-(366+7)*86400). // (366+7) days to include the first week for the heatmap
7070
GroupBy(groupByName).
7171
OrderBy("timestamp").
7272
Find(&hdata)

models/fixtures/hook_task.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
id: 2
1919
hook_id: 1
2020
uuid: uuid2
21-
is_delivered: false
21+
is_delivered: true
2222

2323
-
2424
id: 3

models/git/branch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func FindRecentlyPushedNewBranches(ctx context.Context, doer *user_model.User, o
487487
ForkFrom: opts.BaseRepo.ID,
488488
Archived: optional.Some(false),
489489
}
490-
repoCond := repo_model.SearchRepositoryCondition(&repoOpts).And(repo_model.AccessibleRepositoryCondition(doer, unit.TypeCode))
490+
repoCond := repo_model.SearchRepositoryCondition(repoOpts).And(repo_model.AccessibleRepositoryCondition(doer, unit.TypeCode))
491491
if opts.Repo.ID == opts.BaseRepo.ID {
492492
// should also include the base repo's branches
493493
repoCond = repoCond.Or(builder.Eq{"id": opts.BaseRepo.ID})

models/issues/issue_label.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func DeleteIssueLabel(ctx context.Context, issue *Issue, label *Label, doer *use
206206
}
207207

208208
issue.Labels = nil
209+
issue.isLabelsLoaded = false
209210
return issue.LoadLabels(ctx)
210211
}
211212

models/repo/pushmirror_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ func TestPushMirrorsIterate(t *testing.T) {
3939
Interval: 0,
4040
})
4141

42-
time.Sleep(1 * time.Millisecond)
43-
4442
repo_model.PushMirrorsIterate(db.DefaultContext, 1, func(idx int, bean any) error {
4543
m, ok := bean.(*repo_model.PushMirror)
4644
assert.True(t, ok)

models/repo/repo_list.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func UserOrgPublicUnitRepoCond(userID, orgID int64) builder.Cond {
359359
}
360360

361361
// SearchRepositoryCondition creates a query condition according search repository options
362-
func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
362+
func SearchRepositoryCondition(opts SearchRepoOptions) builder.Cond {
363363
cond := builder.NewCond()
364364

365365
if opts.Private {
@@ -551,18 +551,18 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
551551

552552
// SearchRepository returns repositories based on search options,
553553
// it returns results in given range and number of total results.
554-
func SearchRepository(ctx context.Context, opts *SearchRepoOptions) (RepositoryList, int64, error) {
554+
func SearchRepository(ctx context.Context, opts SearchRepoOptions) (RepositoryList, int64, error) {
555555
cond := SearchRepositoryCondition(opts)
556556
return SearchRepositoryByCondition(ctx, opts, cond, true)
557557
}
558558

559559
// CountRepository counts repositories based on search options,
560-
func CountRepository(ctx context.Context, opts *SearchRepoOptions) (int64, error) {
560+
func CountRepository(ctx context.Context, opts SearchRepoOptions) (int64, error) {
561561
return db.GetEngine(ctx).Where(SearchRepositoryCondition(opts)).Count(new(Repository))
562562
}
563563

564564
// SearchRepositoryByCondition search repositories by condition
565-
func SearchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, cond builder.Cond, loadAttributes bool) (RepositoryList, int64, error) {
565+
func SearchRepositoryByCondition(ctx context.Context, opts SearchRepoOptions, cond builder.Cond, loadAttributes bool) (RepositoryList, int64, error) {
566566
sess, count, err := searchRepositoryByCondition(ctx, opts, cond)
567567
if err != nil {
568568
return nil, 0, err
@@ -590,23 +590,25 @@ func SearchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, c
590590
return repos, count, nil
591591
}
592592

593-
func searchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, cond builder.Cond) (db.Engine, int64, error) {
594-
if opts.Page <= 0 {
595-
opts.Page = 1
593+
func searchRepositoryByCondition(ctx context.Context, opts SearchRepoOptions, cond builder.Cond) (db.Engine, int64, error) {
594+
page := opts.Page
595+
if page <= 0 {
596+
page = 1
596597
}
597598

598-
if len(opts.OrderBy) == 0 {
599-
opts.OrderBy = db.SearchOrderByAlphabetically
599+
orderBy := opts.OrderBy
600+
if len(orderBy) == 0 {
601+
orderBy = db.SearchOrderByAlphabetically
600602
}
601603

602604
args := make([]any, 0)
603605
if opts.PriorityOwnerID > 0 {
604-
opts.OrderBy = db.SearchOrderBy(fmt.Sprintf("CASE WHEN owner_id = ? THEN 0 ELSE owner_id END, %s", opts.OrderBy))
606+
orderBy = db.SearchOrderBy(fmt.Sprintf("CASE WHEN owner_id = ? THEN 0 ELSE owner_id END, %s", orderBy))
605607
args = append(args, opts.PriorityOwnerID)
606608
} else if strings.Count(opts.Keyword, "/") == 1 {
607609
// With "owner/repo" search times, prioritise results which match the owner field
608610
orgName := strings.Split(opts.Keyword, "/")[0]
609-
opts.OrderBy = db.SearchOrderBy(fmt.Sprintf("CASE WHEN owner_name LIKE ? THEN 0 ELSE 1 END, %s", opts.OrderBy))
611+
orderBy = db.SearchOrderBy(fmt.Sprintf("CASE WHEN owner_name LIKE ? THEN 0 ELSE 1 END, %s", orderBy))
610612
args = append(args, orgName)
611613
}
612614

@@ -623,9 +625,9 @@ func searchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, c
623625
}
624626
}
625627

626-
sess = sess.Where(cond).OrderBy(opts.OrderBy.String(), args...)
628+
sess = sess.Where(cond).OrderBy(orderBy.String(), args...)
627629
if opts.PageSize > 0 {
628-
sess = sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
630+
sess = sess.Limit(opts.PageSize, (page-1)*opts.PageSize)
629631
}
630632
return sess, count, nil
631633
}
@@ -689,14 +691,14 @@ func AccessibleRepositoryCondition(user *user_model.User, unitType unit.Type) bu
689691

690692
// SearchRepositoryByName takes keyword and part of repository name to search,
691693
// it returns results in given range and number of total results.
692-
func SearchRepositoryByName(ctx context.Context, opts *SearchRepoOptions) (RepositoryList, int64, error) {
694+
func SearchRepositoryByName(ctx context.Context, opts SearchRepoOptions) (RepositoryList, int64, error) {
693695
opts.IncludeDescription = false
694696
return SearchRepository(ctx, opts)
695697
}
696698

697699
// SearchRepositoryIDs takes keyword and part of repository name to search,
698700
// it returns results in given range and number of total results.
699-
func SearchRepositoryIDs(ctx context.Context, opts *SearchRepoOptions) ([]int64, int64, error) {
701+
func SearchRepositoryIDs(ctx context.Context, opts SearchRepoOptions) ([]int64, int64, error) {
700702
opts.IncludeDescription = false
701703

702704
cond := SearchRepositoryCondition(opts)
@@ -740,7 +742,7 @@ func FindUserCodeAccessibleOwnerRepoIDs(ctx context.Context, ownerID int64, user
740742
}
741743

742744
// GetUserRepositories returns a list of repositories of given user.
743-
func GetUserRepositories(ctx context.Context, opts *SearchRepoOptions) (RepositoryList, int64, error) {
745+
func GetUserRepositories(ctx context.Context, opts SearchRepoOptions) (RepositoryList, int64, error) {
744746
if len(opts.OrderBy) == 0 {
745747
opts.OrderBy = "updated_unix DESC"
746748
}
@@ -767,5 +769,5 @@ func GetUserRepositories(ctx context.Context, opts *SearchRepoOptions) (Reposito
767769

768770
sess = sess.Where(cond).OrderBy(opts.OrderBy.String())
769771
repos := make(RepositoryList, 0, opts.PageSize)
770-
return repos, count, db.SetSessionPagination(sess, opts).Find(&repos)
772+
return repos, count, db.SetSessionPagination(sess, &opts).Find(&repos)
771773
}

0 commit comments

Comments
 (0)