Skip to content

Commit 77da820

Browse files
authored
Merge branch 'main' into add-is_archived-in-issue-index
2 parents 792c54f + 39a0101 commit 77da820

File tree

143 files changed

+3216
-1712
lines changed

Some content is hidden

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

143 files changed

+3216
-1712
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ rules:
818818
unicorn/consistent-destructuring: [2]
819819
unicorn/consistent-empty-array-spread: [2]
820820
unicorn/consistent-existence-index-check: [0]
821-
unicorn/consistent-function-scoping: [2]
821+
unicorn/consistent-function-scoping: [0]
822822
unicorn/custom-error-definition: [0]
823823
unicorn/empty-brace-spaces: [2]
824824
unicorn/error-message: [0]

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ require (
121121
github.com/yuin/goldmark v1.7.8
122122
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
123123
github.com/yuin/goldmark-meta v1.1.0
124-
golang.org/x/crypto v0.28.0
124+
golang.org/x/crypto v0.31.0
125125
golang.org/x/image v0.21.0
126126
golang.org/x/net v0.30.0
127127
golang.org/x/oauth2 v0.23.0
128-
golang.org/x/sync v0.8.0
129-
golang.org/x/sys v0.26.0
130-
golang.org/x/text v0.19.0
128+
golang.org/x/sync v0.10.0
129+
golang.org/x/sys v0.28.0
130+
golang.org/x/text v0.21.0
131131
golang.org/x/tools v0.26.0
132132
google.golang.org/grpc v1.67.1
133133
google.golang.org/protobuf v1.35.1

go.sum

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,9 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
893893
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
894894
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
895895
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
896-
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
897896
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
897+
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
898+
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
898899
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
899900
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
900901
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
@@ -946,8 +947,9 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
946947
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
947948
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
948949
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
949-
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
950950
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
951+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
952+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
951953
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
952954
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
953955
golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -982,8 +984,9 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
982984
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
983985
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
984986
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
985-
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
986987
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
988+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
989+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
987990
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
988991
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
989992
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -996,8 +999,9 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
996999
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
9971000
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
9981001
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
999-
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
10001002
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
1003+
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
1004+
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
10011005
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
10021006
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
10031007
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -1009,8 +1013,9 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
10091013
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
10101014
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
10111015
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
1012-
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
10131016
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
1017+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
1018+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
10141019
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
10151020
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
10161021
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

models/db/search.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ const (
2626
SearchOrderByForksReverse SearchOrderBy = "num_forks DESC"
2727
)
2828

29-
const (
30-
// Which means a condition to filter the records which don't match any id.
31-
// It's different from zero which means the condition could be ignored.
32-
NoConditionID = -1
33-
)
29+
// NoConditionID means a condition to filter the records which don't match any id.
30+
// eg: "milestone_id=-1" means "find the items without any milestone.
31+
const NoConditionID int64 = -1
32+
33+
// NonExistingID means a condition to match no result (eg: a non-existing user)
34+
// It doesn't use -1 or -2 because they are used as builtin users.
35+
const NonExistingID int64 = -1000000

models/fixtures/review.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
reviewer_id: 1
55
issue_id: 2
66
content: "Demo Review"
7+
original_author_id: 0
78
updated_unix: 946684810
89
created_unix: 946684810
910
-
@@ -12,6 +13,7 @@
1213
reviewer_id: 534543
1314
issue_id: 534543
1415
content: "Invalid Review #1"
16+
original_author_id: 0
1517
updated_unix: 946684810
1618
created_unix: 946684810
1719
-
@@ -20,6 +22,7 @@
2022
reviewer_id: 1
2123
issue_id: 343545
2224
content: "Invalid Review #2"
25+
original_author_id: 0
2326
updated_unix: 946684810
2427
created_unix: 946684810
2528
-
@@ -28,6 +31,7 @@
2831
reviewer_id: 1
2932
issue_id: 2
3033
content: "Pending Review"
34+
original_author_id: 0
3135
updated_unix: 946684810
3236
created_unix: 946684810
3337
-
@@ -36,6 +40,7 @@
3640
reviewer_id: 1
3741
issue_id: 3
3842
content: "New review 1"
43+
original_author_id: 0
3944
updated_unix: 946684810
4045
created_unix: 946684810
4146
-
@@ -61,8 +66,8 @@
6166
type: 1
6267
reviewer_id: 4
6368
issue_id: 3
64-
original_author_id: 0
6569
content: "New review 5"
70+
original_author_id: 0
6671
commit_id: 8091a55037cd59e47293aca02981b5a67076b364
6772
stale: true
6873
updated_unix: 946684813
@@ -73,16 +78,17 @@
7378
reviewer_id: 2
7479
issue_id: 3
7580
content: "New review 3 rejected"
81+
original_author_id: 0
7682
updated_unix: 946684814
7783
created_unix: 946684814
78-
original_author_id: 0
7984

8085
-
8186
id: 10
8287
type: 3
8388
reviewer_id: 100
8489
issue_id: 3
8590
content: "a deleted user's review"
91+
original_author_id: 0
8692
official: true
8793
updated_unix: 946684815
8894
created_unix: 946684815
@@ -112,6 +118,7 @@
112118
reviewer_id: 5
113119
issue_id: 11
114120
content: "old review from user5"
121+
original_author_id: 0
115122
updated_unix: 946684820
116123
created_unix: 946684820
117124

@@ -121,6 +128,7 @@
121128
reviewer_id: 5
122129
issue_id: 11
123130
content: "duplicate review from user5 (latest)"
131+
original_author_id: 0
124132
updated_unix: 946684830
125133
created_unix: 946684830
126134

@@ -130,6 +138,7 @@
130138
reviewer_id: 6
131139
issue_id: 11
132140
content: "singular review from org6 and final review for this pr"
141+
original_author_id: 0
133142
updated_unix: 946684831
134143
created_unix: 946684831
135144

@@ -139,6 +148,7 @@
139148
reviewer_id: 20
140149
issue_id: 20
141150
content: "review request for user20"
151+
original_author_id: 0
142152
updated_unix: 946684832
143153
created_unix: 946684832
144154

@@ -148,6 +158,7 @@
148158
reviewer_id: 20
149159
issue_id: 20
150160
content: "review approved by user20"
161+
original_author_id: 0
151162
updated_unix: 946684833
152163
created_unix: 946684833
153164

@@ -158,6 +169,7 @@
158169
reviewer_team_id: 5
159170
issue_id: 20
160171
content: "review request for team5"
172+
original_author_id: 0
161173
updated_unix: 946684834
162174
created_unix: 946684834
163175

@@ -168,6 +180,7 @@
168180
reviewer_team_id: 0
169181
issue_id: 20
170182
content: "review request for user15"
183+
original_author_id: 0
171184
updated_unix: 946684835
172185
created_unix: 946684835
173186

@@ -177,6 +190,7 @@
177190
reviewer_id: 1
178191
issue_id: 2
179192
content: "Review Comment"
193+
original_author_id: 0
180194
updated_unix: 946684810
181195
created_unix: 946684810
182196

@@ -186,6 +200,7 @@
186200
reviewer_id: 5
187201
issue_id: 3
188202
content: "reviewed by user5"
203+
original_author_id: 0
189204
commit_id: 4a357436d925b5c974181ff12a994538ddc5a269
190205
updated_unix: 946684816
191206
created_unix: 946684816
@@ -196,5 +211,6 @@
196211
reviewer_id: 5
197212
issue_id: 3
198213
content: "review request for user5"
214+
original_author_id: 0
199215
updated_unix: 946684817
200216
created_unix: 946684817

models/issues/issue_search.go

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ type IssuesOptions struct { //nolint
2727
RepoIDs []int64 // overwrites RepoCond if the length is not 0
2828
AllPublic bool // include also all public repositories
2929
RepoCond builder.Cond
30-
AssigneeID int64
31-
PosterID int64
30+
AssigneeID optional.Option[int64]
31+
PosterID optional.Option[int64]
3232
MentionedID int64
3333
ReviewRequestedID int64
3434
ReviewedID int64
@@ -231,15 +231,8 @@ func applyConditions(sess *xorm.Session, opts *IssuesOptions) {
231231
sess.And("issue.is_closed=?", opts.IsClosed.Value())
232232
}
233233

234-
if opts.AssigneeID > 0 {
235-
applyAssigneeCondition(sess, opts.AssigneeID)
236-
} else if opts.AssigneeID == db.NoConditionID {
237-
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)")
238-
}
239-
240-
if opts.PosterID > 0 {
241-
applyPosterCondition(sess, opts.PosterID)
242-
}
234+
applyAssigneeCondition(sess, opts.AssigneeID)
235+
applyPosterCondition(sess, opts.PosterID)
243236

244237
if opts.MentionedID > 0 {
245238
applyMentionedCondition(sess, opts.MentionedID)
@@ -359,13 +352,27 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, org *organizati
359352
return cond
360353
}
361354

362-
func applyAssigneeCondition(sess *xorm.Session, assigneeID int64) {
363-
sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
364-
And("issue_assignees.assignee_id = ?", assigneeID)
355+
func applyAssigneeCondition(sess *xorm.Session, assigneeID optional.Option[int64]) {
356+
// old logic: 0 is also treated as "not filtering assignee", because the "assignee" was read as FormInt64
357+
if !assigneeID.Has() || assigneeID.Value() == 0 {
358+
return
359+
}
360+
if assigneeID.Value() == db.NoConditionID {
361+
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)")
362+
} else {
363+
sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
364+
And("issue_assignees.assignee_id = ?", assigneeID.Value())
365+
}
365366
}
366367

367-
func applyPosterCondition(sess *xorm.Session, posterID int64) {
368-
sess.And("issue.poster_id=?", posterID)
368+
func applyPosterCondition(sess *xorm.Session, posterID optional.Option[int64]) {
369+
if !posterID.Has() {
370+
return
371+
}
372+
// poster doesn't need to support db.NoConditionID(-1), so just use the value as-is
373+
if posterID.Has() {
374+
sess.And("issue.poster_id=?", posterID.Value())
375+
}
369376
}
370377

371378
func applyMentionedCondition(sess *xorm.Session, mentionedID int64) {

models/issues/issue_stats.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,9 @@ func applyIssuesOptions(sess *xorm.Session, opts *IssuesOptions, issueIDs []int6
151151

152152
applyProjectCondition(sess, opts)
153153

154-
if opts.AssigneeID > 0 {
155-
applyAssigneeCondition(sess, opts.AssigneeID)
156-
} else if opts.AssigneeID == db.NoConditionID {
157-
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)")
158-
}
154+
applyAssigneeCondition(sess, opts.AssigneeID)
159155

160-
if opts.PosterID > 0 {
161-
applyPosterCondition(sess, opts.PosterID)
162-
}
156+
applyPosterCondition(sess, opts.PosterID)
163157

164158
if opts.MentionedID > 0 {
165159
applyMentionedCondition(sess, opts.MentionedID)

models/issues/issue_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
repo_model "code.gitea.io/gitea/models/repo"
1717
"code.gitea.io/gitea/models/unittest"
1818
user_model "code.gitea.io/gitea/models/user"
19+
"code.gitea.io/gitea/modules/optional"
1920
"code.gitea.io/gitea/modules/setting"
2021

2122
"github.com/stretchr/testify/assert"
@@ -155,7 +156,7 @@ func TestIssues(t *testing.T) {
155156
}{
156157
{
157158
issues_model.IssuesOptions{
158-
AssigneeID: 1,
159+
AssigneeID: optional.Some(int64(1)),
159160
SortType: "oldest",
160161
},
161162
[]int64{1, 6},

0 commit comments

Comments
 (0)