Skip to content

Commit f4c5144

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: (21 commits) Use 8 as default value for git lfs concurrency (go-gitea#32421) Fix milestone deadline and date related problems (go-gitea#32339) Only query team tables if repository is under org when getting assignees (go-gitea#32414) Refactor RepoRefByType (go-gitea#32413) Refactor template ctx and render utils (go-gitea#32422) Refactor DateUtils and merge TimeSince (go-gitea#32409) Refactor markup package (go-gitea#32399) Add some handy markdown editor features (go-gitea#32400) Make LFS http_client parallel within a batch. (go-gitea#32369) Refactor repo legacy (go-gitea#32404) Replace DateTime with proper functions (go-gitea#32402) Fix git error handling (go-gitea#32401) Fix created_unix for mirroring (go-gitea#32342) Replace DateTime with DateUtils (go-gitea#32383) improve performance of diffs (go-gitea#32393) Refactor tests to prevent from unnecessary preparations (go-gitea#32398) Add artifacts test fixture (go-gitea#30300) Fix `missing signature key` error when pulling Docker images with `SERVE_DIRECT` enabled (go-gitea#32365) Fix a number of typescript issues (go-gitea#32308) Update go dependencies (go-gitea#32389) ...
2 parents b594773 + 41b4ef8 commit f4c5144

File tree

237 files changed

+6073
-5356
lines changed

Some content is hidden

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

237 files changed

+6073
-5356
lines changed

.eslintrc.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ plugins:
2727
- "@stylistic/eslint-plugin-js"
2828
- "@typescript-eslint/eslint-plugin"
2929
- eslint-plugin-array-func
30-
- eslint-plugin-deprecation
3130
- eslint-plugin-github
3231
- eslint-plugin-i
3332
- eslint-plugin-no-jquery
@@ -248,6 +247,7 @@ rules:
248247
"@typescript-eslint/no-base-to-string": [0]
249248
"@typescript-eslint/no-confusing-non-null-assertion": [2]
250249
"@typescript-eslint/no-confusing-void-expression": [0]
250+
"@typescript-eslint/no-deprecated": [2]
251251
"@typescript-eslint/no-dupe-class-members": [0]
252252
"@typescript-eslint/no-duplicate-enum-values": [2]
253253
"@typescript-eslint/no-duplicate-type-constituents": [2, {ignoreUnions: true}]
@@ -359,7 +359,6 @@ rules:
359359
default-case-last: [2]
360360
default-case: [0]
361361
default-param-last: [0]
362-
deprecation/deprecation: [2]
363362
dot-notation: [0]
364363
eqeqeq: [2]
365364
for-direction: [2]
@@ -816,6 +815,7 @@ rules:
816815
unicorn/catch-error-name: [0]
817816
unicorn/consistent-destructuring: [2]
818817
unicorn/consistent-empty-array-spread: [2]
818+
unicorn/consistent-existence-index-check: [0]
819819
unicorn/consistent-function-scoping: [2]
820820
unicorn/custom-error-definition: [0]
821821
unicorn/empty-brace-spaces: [2]
@@ -892,10 +892,12 @@ rules:
892892
unicorn/prefer-dom-node-text-content: [2]
893893
unicorn/prefer-event-target: [2]
894894
unicorn/prefer-export-from: [0]
895+
unicorn/prefer-global-this: [0]
895896
unicorn/prefer-includes: [2]
896897
unicorn/prefer-json-parse-buffer: [0]
897898
unicorn/prefer-keyboard-event-key: [2]
898899
unicorn/prefer-logical-operator-over-ternary: [2]
900+
unicorn/prefer-math-min-max: [2]
899901
unicorn/prefer-math-trunc: [2]
900902
unicorn/prefer-modern-dom-apis: [0]
901903
unicorn/prefer-modern-math-apis: [2]

assets/go-licenses.json

+11-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom/conf/app.example.ini

+7-1
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 = 8
26482654

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

go.mod

+95-98
Large diffs are not rendered by default.

go.sum

+226-236
Large diffs are not rendered by default.

models/actions/schedule_spec_test.go

+3-5
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/fixtures/action_artifact.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
-
2+
id: 1
3+
run_id: 791
4+
runner_id: 1
5+
repo_id: 4
6+
owner_id: 1
7+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
8+
storage_path: "26/1/1712166500347189545.chunk"
9+
file_size: 1024
10+
file_compressed_size: 1024
11+
content_encoding: ""
12+
artifact_path: "abc.txt"
13+
artifact_name: "artifact-download"
14+
status: 1
15+
created_unix: 1712338649
16+
updated_unix: 1712338649
17+
expired_unix: 1720114649
18+
19+
-
20+
id: 19
21+
run_id: 791
22+
runner_id: 1
23+
repo_id: 4
24+
owner_id: 1
25+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
26+
storage_path: "26/19/1712348022422036662.chunk"
27+
file_size: 1024
28+
file_compressed_size: 1024
29+
content_encoding: ""
30+
artifact_path: "abc.txt"
31+
artifact_name: "multi-file-download"
32+
status: 2
33+
created_unix: 1712348022
34+
updated_unix: 1712348022
35+
expired_unix: 1720124022
36+
37+
-
38+
id: 20
39+
run_id: 791
40+
runner_id: 1
41+
repo_id: 4
42+
owner_id: 1
43+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
44+
storage_path: "26/20/1712348022423431524.chunk"
45+
file_size: 1024
46+
file_compressed_size: 1024
47+
content_encoding: ""
48+
artifact_path: "xyz/def.txt"
49+
artifact_name: "multi-file-download"
50+
status: 2
51+
created_unix: 1712348022
52+
updated_unix: 1712348022
53+
expired_unix: 1720124022
54+
55+
-
56+
id: 22
57+
run_id: 792
58+
runner_id: 1
59+
repo_id: 4
60+
owner_id: 1
61+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
62+
storage_path: "27/5/1730330775594233150.chunk"
63+
file_size: 1024
64+
file_compressed_size: 1024
65+
content_encoding: "application/zip"
66+
artifact_path: "artifact-v4-download.zip"
67+
artifact_name: "artifact-v4-download"
68+
status: 2
69+
created_unix: 1730330775
70+
updated_unix: 1730330775
71+
expired_unix: 1738106775

models/issues/milestone.go

+1-2
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

+1
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

+21
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

+16-14
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,28 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us
110110
return nil, err
111111
}
112112

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

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

modules/git/error.go

+9-31
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,14 @@
44
package git
55

66
import (
7+
"context"
8+
"errors"
79
"fmt"
810
"strings"
9-
"time"
1011

1112
"code.gitea.io/gitea/modules/util"
1213
)
1314

14-
// ErrExecTimeout error when exec timed out
15-
type ErrExecTimeout struct {
16-
Duration time.Duration
17-
}
18-
19-
// IsErrExecTimeout if some error is ErrExecTimeout
20-
func IsErrExecTimeout(err error) bool {
21-
_, ok := err.(ErrExecTimeout)
22-
return ok
23-
}
24-
25-
func (err ErrExecTimeout) Error() string {
26-
return fmt.Sprintf("execution is timeout [duration: %v]", err.Duration)
27-
}
28-
2915
// ErrNotExist commit not exist error
3016
type ErrNotExist struct {
3117
ID string
@@ -62,21 +48,6 @@ func IsErrBadLink(err error) bool {
6248
return ok
6349
}
6450

65-
// ErrUnsupportedVersion error when required git version not matched
66-
type ErrUnsupportedVersion struct {
67-
Required string
68-
}
69-
70-
// IsErrUnsupportedVersion if some error is ErrUnsupportedVersion
71-
func IsErrUnsupportedVersion(err error) bool {
72-
_, ok := err.(ErrUnsupportedVersion)
73-
return ok
74-
}
75-
76-
func (err ErrUnsupportedVersion) Error() string {
77-
return fmt.Sprintf("Operation requires higher version [required: %s]", err.Required)
78-
}
79-
8051
// ErrBranchNotExist represents a "BranchNotExist" kind of error.
8152
type ErrBranchNotExist struct {
8253
Name string
@@ -185,3 +156,10 @@ func IsErrMoreThanOne(err error) bool {
185156
func (err *ErrMoreThanOne) Error() string {
186157
return fmt.Sprintf("ErrMoreThanOne Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
187158
}
159+
160+
func IsErrCanceledOrKilled(err error) bool {
161+
// When "cancel()" a git command's context, the returned error of "Run()" could be one of them:
162+
// - context.Canceled
163+
// - *exec.ExitError: "signal: killed"
164+
return err != nil && (errors.Is(err, context.Canceled) || err.Error() == "signal: killed")
165+
}

modules/git/repo_attribute.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ func (c *CheckAttributeReader) Run() error {
166166
Stdout: c.stdOut,
167167
Stderr: stdErr,
168168
})
169-
if err != nil && // If there is an error we need to return but:
170-
c.ctx.Err() != err && // 1. Ignore the context error if the context is cancelled or exceeds the deadline (RunWithContext could return c.ctx.Err() which is Canceled or DeadlineExceeded)
171-
err.Error() != "signal: killed" { // 2. We should not pass up errors due to the program being killed
169+
if err != nil && !IsErrCanceledOrKilled(err) {
172170
return fmt.Errorf("failed to run attr-check. Error: %w\nStderr: %s", err, stdErr.String())
173171
}
174172
return nil

modules/gitgraph/graph.go

+1-1
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

+11-2
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
}

0 commit comments

Comments
 (0)