Skip to content

Commit 1b496bd

Browse files
committed
Merge branch 'main' into lunny/fix_get_reviewers_bug
2 parents bcc78c3 + 24b83ff commit 1b496bd

File tree

166 files changed

+2225
-1948
lines changed

Some content is hidden

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

166 files changed

+2225
-1948
lines changed

custom/conf/app.example.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2642,9 +2642,15 @@ LEVEL = Info
26422642
;; override the azure blob base path if storage type is azureblob
26432643
;AZURE_BLOB_BASE_PATH = lfs/
26442644

2645+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2646+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2647+
;; settings for Gitea's LFS client (eg: mirroring an upstream lfs endpoint)
2648+
;;
26452649
;[lfs_client]
2646-
;; When mirroring an upstream lfs endpoint, limit the number of pointers in each batch request to this number
2650+
;; Limit the number of pointers in each batch request to this number
26472651
;BATCH_SIZE = 20
2652+
;; Limit the number of concurrent upload/download operations within a batch
2653+
;BATCH_OPERATION_CONCURRENCY = 3
26482654

26492655
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26502656
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ require (
124124
golang.org/x/image v0.21.0
125125
golang.org/x/net v0.30.0
126126
golang.org/x/oauth2 v0.23.0
127+
golang.org/x/sync v0.8.0
127128
golang.org/x/sys v0.26.0
128129
golang.org/x/text v0.19.0
129130
golang.org/x/tools v0.26.0
@@ -316,7 +317,6 @@ require (
316317
go.uber.org/zap v1.27.0 // indirect
317318
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
318319
golang.org/x/mod v0.21.0 // indirect
319-
golang.org/x/sync v0.8.0 // indirect
320320
golang.org/x/time v0.7.0 // indirect
321321
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
322322
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect

models/actions/schedule_spec_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ import (
77
"testing"
88
"time"
99

10+
"code.gitea.io/gitea/modules/test"
11+
1012
"github.com/stretchr/testify/assert"
1113
"github.com/stretchr/testify/require"
1214
)
1315

1416
func TestActionScheduleSpec_Parse(t *testing.T) {
1517
// Mock the local timezone is not UTC
16-
local := time.Local
1718
tz, err := time.LoadLocation("Asia/Shanghai")
1819
require.NoError(t, err)
19-
defer func() {
20-
time.Local = local
21-
}()
22-
time.Local = tz
20+
defer test.MockVariableValue(&time.Local, tz)()
2321

2422
now, err := time.Parse(time.RFC3339, "2024-07-31T15:47:55+08:00")
2523
require.NoError(t, err)

models/issues/milestone.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ func (m *Milestone) BeforeUpdate() {
8484
// this object.
8585
func (m *Milestone) AfterLoad() {
8686
m.NumOpenIssues = m.NumIssues - m.NumClosedIssues
87-
if m.DeadlineUnix.Year() == 9999 {
87+
if m.DeadlineUnix == 0 {
8888
return
8989
}
90-
9190
m.DeadlineString = m.DeadlineUnix.FormatDate()
9291
if m.IsClosed {
9392
m.IsOverdue = m.ClosedDateUnix >= m.DeadlineUnix

models/migrations/migrations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ func prepareMigrationTasks() []*migration {
364364
newMigration(304, "Add index for release sha1", v1_23.AddIndexForReleaseSha1),
365365
newMigration(305, "Add Repository Licenses", v1_23.AddRepositoryLicenses),
366366
newMigration(306, "Add BlockAdminMergeOverride to ProtectedBranch", v1_23.AddBlockAdminMergeOverrideBranchProtection),
367+
newMigration(307, "Fix milestone deadline_unix when there is no due date", v1_23.FixMilestoneNoDueDate),
367368
}
368369
return preparedMigrations
369370
}

models/migrations/v1_23/v307.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_23 //nolint
5+
6+
import (
7+
"code.gitea.io/gitea/modules/timeutil"
8+
9+
"xorm.io/xorm"
10+
)
11+
12+
func FixMilestoneNoDueDate(x *xorm.Engine) error {
13+
type Milestone struct {
14+
DeadlineUnix timeutil.TimeStamp
15+
}
16+
// Wednesday, December 1, 9999 12:00:00 AM GMT+00:00
17+
_, err := x.Table("milestone").Where("deadline_unix > 253399622400").
18+
Cols("deadline_unix").
19+
Update(&Milestone{DeadlineUnix: 0})
20+
return err
21+
}

models/repo/user_repo.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,28 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us
109109
return nil, err
110110
}
111111

112-
additionalUserIDs := make([]int64, 0, 10)
113-
if err = e.Table("team_user").
114-
Join("INNER", "team_repo", "`team_repo`.team_id = `team_user`.team_id").
115-
Join("INNER", "team_unit", "`team_unit`.team_id = `team_user`.team_id").
116-
Where("`team_repo`.repo_id = ? AND (`team_unit`.access_mode >= ? OR (`team_unit`.access_mode = ? AND `team_unit`.`type` = ?))",
117-
repo.ID, perm.AccessModeWrite, perm.AccessModeRead, unit.TypePullRequests).
118-
Distinct("`team_user`.uid").
119-
Select("`team_user`.uid").
120-
Find(&additionalUserIDs); err != nil {
121-
return nil, err
122-
}
123-
124112
uniqueUserIDs := make(container.Set[int64])
125113
uniqueUserIDs.AddMultiple(userIDs...)
126-
uniqueUserIDs.AddMultiple(additionalUserIDs...)
114+
115+
if repo.Owner.IsOrganization() {
116+
additionalUserIDs := make([]int64, 0, 10)
117+
if err = e.Table("team_user").
118+
Join("INNER", "team_repo", "`team_repo`.team_id = `team_user`.team_id").
119+
Join("INNER", "team_unit", "`team_unit`.team_id = `team_user`.team_id").
120+
Where("`team_repo`.repo_id = ? AND (`team_unit`.access_mode >= ? OR (`team_unit`.access_mode = ? AND `team_unit`.`type` = ?))",
121+
repo.ID, perm.AccessModeWrite, perm.AccessModeRead, unit.TypePullRequests).
122+
Distinct("`team_user`.uid").
123+
Select("`team_user`.uid").
124+
Find(&additionalUserIDs); err != nil {
125+
return nil, err
126+
}
127+
uniqueUserIDs.AddMultiple(additionalUserIDs...)
128+
}
127129

128130
// Leave a seat for owner itself to append later, but if owner is an organization
129131
// and just waste 1 unit is cheaper than re-allocate memory once.
130132
users := make([]*user_model.User, 0, len(uniqueUserIDs)+1)
131-
if len(userIDs) > 0 {
133+
if len(uniqueUserIDs) > 0 {
132134
if err = e.In("id", uniqueUserIDs.Values()).
133135
Where(builder.Eq{"`user`.is_active": true}).
134136
OrderBy(user_model.GetOrderByName()).

modules/gitgraph/graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo
3232
graphCmd.AddArguments("--all")
3333
}
3434

35-
graphCmd.AddArguments("-C", "-M", "--date=iso").
35+
graphCmd.AddArguments("-C", "-M", "--date=iso-strict").
3636
AddOptionFormat("-n %d", setting.UI.GraphMaxCommitNum*page).
3737
AddOptionFormat("--pretty=format:%s", format)
3838

modules/gitgraph/graph_models.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"fmt"
1010
"strings"
11+
"time"
1112

1213
asymkey_model "code.gitea.io/gitea/models/asymkey"
1314
"code.gitea.io/gitea/models/db"
@@ -192,6 +193,14 @@ var RelationCommit = &Commit{
192193
Row: -1,
193194
}
194195

196+
func parseGitTime(timeStr string) time.Time {
197+
t, err := time.Parse(time.RFC3339, timeStr)
198+
if err != nil {
199+
return time.Unix(0, 0)
200+
}
201+
return t
202+
}
203+
195204
// NewCommit creates a new commit from a provided line
196205
func NewCommit(row, column int, line []byte) (*Commit, error) {
197206
data := bytes.SplitN(line, []byte("|"), 5)
@@ -206,7 +215,7 @@ func NewCommit(row, column int, line []byte) (*Commit, error) {
206215
// 1 matches git log --pretty=format:%H => commit hash
207216
Rev: string(data[1]),
208217
// 2 matches git log --pretty=format:%ad => author date (format respects --date= option)
209-
Date: string(data[2]),
218+
Date: parseGitTime(string(data[2])),
210219
// 3 matches git log --pretty=format:%h => abbreviated commit hash
211220
ShortRev: string(data[3]),
212221
// 4 matches git log --pretty=format:%s => subject
@@ -245,7 +254,7 @@ type Commit struct {
245254
Column int
246255
Refs []git.Reference
247256
Rev string
248-
Date string
257+
Date time.Time
249258
ShortRev string
250259
Subject string
251260
}

modules/gitrepo/gitrepo.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"code.gitea.io/gitea/modules/git"
1313
"code.gitea.io/gitea/modules/setting"
14+
"code.gitea.io/gitea/modules/util"
1415
)
1516

1617
type Repository interface {
@@ -59,15 +60,11 @@ func repositoryFromContext(ctx context.Context, repo Repository) *git.Repository
5960
return nil
6061
}
6162

62-
type nopCloser func()
63-
64-
func (nopCloser) Close() error { return nil }
65-
6663
// RepositoryFromContextOrOpen attempts to get the repository from the context or just opens it
6764
func RepositoryFromContextOrOpen(ctx context.Context, repo Repository) (*git.Repository, io.Closer, error) {
6865
gitRepo := repositoryFromContext(ctx, repo)
6966
if gitRepo != nil {
70-
return gitRepo, nopCloser(nil), nil
67+
return gitRepo, util.NopCloser{}, nil
7168
}
7269

7370
gitRepo, err := OpenRepository(ctx, repo)
@@ -95,7 +92,7 @@ func repositoryFromContextPath(ctx context.Context, path string) *git.Repository
9592
func RepositoryFromContextOrOpenPath(ctx context.Context, path string) (*git.Repository, io.Closer, error) {
9693
gitRepo := repositoryFromContextPath(ctx, path)
9794
if gitRepo != nil {
98-
return gitRepo, nopCloser(nil), nil
95+
return gitRepo, util.NopCloser{}, nil
9996
}
10097

10198
gitRepo, err := git.OpenRepository(ctx, path)

0 commit comments

Comments
 (0)