Skip to content

Commit b1e4857

Browse files
committed
Merge branch 'main' into overflow-menu
* main: fix missed RenderLabel change in card template (go-gitea#29772) Fix incorrect locale Tr for gpg command (go-gitea#29754) Improve a11y document and dropdown item (go-gitea#29753) Improve QueryEscape helper function (go-gitea#29768) Use relative links for commits, mentions, and issues in markdown (go-gitea#29427) Move fork router functions to a standalone file (go-gitea#29756) Configure pinned JS dependencies via updates.config.js (go-gitea#29696) Refactor to use optional.Option for issue index search option (go-gitea#29739) Fix user router possbile panic (go-gitea#29751) Refactor label.IsArchived() (go-gitea#29750) Fix date rendering by adding `<gitea-absolute-date>` (go-gitea#29725) Update to labeler v5 (go-gitea#29721) Update Chroma to v2.13.0 (go-gitea#29732)
2 parents 9c2fdb9 + 712e19f commit b1e4857

File tree

44 files changed

+677
-542
lines changed

Some content is hidden

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

44 files changed

+677
-542
lines changed

.github/labeler.yml

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,84 @@
11
modifies/docs:
2-
- "**/*.md"
3-
- "docs/**"
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- "**/*.md"
5+
- "docs/**"
46

57
modifies/frontend:
6-
- "web_src/**/*"
8+
- changed-files:
9+
- any-glob-to-any-file:
10+
- "web_src/**"
11+
- "tailwind.config.js"
12+
- "webpack.config.js"
713

814
modifies/templates:
9-
- all: ["templates/**", "!templates/swagger/v1_json.tmpl"]
15+
- changed-files:
16+
- all-globs-to-any-file:
17+
- "templates/**"
18+
- "!templates/swagger/v1_json.tmpl"
1019

1120
modifies/api:
12-
- "routers/api/**"
13-
- "templates/swagger/v1_json.tmpl"
21+
- changed-files:
22+
- any-glob-to-any-file:
23+
- "routers/api/**"
24+
- "templates/swagger/v1_json.tmpl"
1425

1526
modifies/cli:
16-
- "cmd/**"
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- "cmd/**"
1730

1831
modifies/translation:
19-
- "options/locale/*.ini"
32+
- changed-files:
33+
- any-glob-to-any-file:
34+
- "options/locale/*.ini"
2035

2136
modifies/migrations:
22-
- "models/migrations/**/*"
37+
- changed-files:
38+
- any-glob-to-any-file:
39+
- "models/migrations/**"
2340

2441
modifies/internal:
25-
- "Makefile"
26-
- "Dockerfile"
27-
- "Dockerfile.rootless"
28-
- "docker/**"
29-
- "webpack.config.js"
30-
- ".eslintrc.yaml"
31-
- ".golangci.yml"
32-
- ".markdownlint.yaml"
33-
- ".spectral.yaml"
34-
- ".stylelintrc.yaml"
35-
- ".yamllint.yaml"
36-
- ".github/**"
42+
- changed-files:
43+
- any-glob-to-any-file:
44+
- ".air.toml"
45+
- "Makefile"
46+
- "Dockerfile"
47+
- "Dockerfile.rootless"
48+
- ".dockerignore"
49+
- "docker/**"
50+
- ".editorconfig"
51+
- ".eslintrc.yaml"
52+
- ".golangci.yml"
53+
- ".gitpod.yml"
54+
- ".markdownlint.yaml"
55+
- ".spectral.yaml"
56+
- ".stylelintrc.yaml"
57+
- ".yamllint.yaml"
58+
- ".github/**"
59+
- ".gitea/"
60+
- ".devcontainer/**"
61+
- "build.go"
62+
- "build/**"
63+
- "contrib/**"
64+
65+
modifies/dependencies:
66+
- changed-files:
67+
- any-glob-to-any-file:
68+
- "package.json"
69+
- "package-lock.json"
70+
- "poetry.toml"
71+
- "poetry.lock"
72+
- "go.mod"
73+
- "go.sum"
74+
- "pyproject.toml"
75+
76+
modifies/go:
77+
- changed-files:
78+
- any-glob-to-any-file:
79+
- "**/*.go"
80+
81+
modifies/js:
82+
- changed-files:
83+
- any-glob-to-any-file:
84+
- "**/*.js"

.github/workflows/pull-labeler.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
label:
12+
labeler:
1313
runs-on: ubuntu-latest
1414
permissions:
1515
contents: read
1616
pull-requests: write
1717
steps:
18-
- uses: actions/labeler@v4
18+
- uses: actions/labeler@v5
1919
with:
20-
dot: true
20+
sync-labels: true

docs/content/contributing/guidelines-frontend.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。
5353
### 可访问性 / ARIA
5454

5555
在历史上,Gitea大量使用了可访问性不友好的框架 Fomantic UI。
56-
Gitea使用一些补丁使Fomantic UI更具可访问性(参见`aria.js``aria.md`),
56+
Gitea 使用一些补丁使 Fomantic UI 更具可访问性(参见 `aria.md`),
5757
但仍然存在许多问题需要大量的工作和时间来修复。
5858

5959
### 框架使用

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
1818
github.com/NYTimes/gziphandler v1.1.1
1919
github.com/PuerkitoBio/goquery v1.8.1
20-
github.com/alecthomas/chroma/v2 v2.12.0
20+
github.com/alecthomas/chroma/v2 v2.13.0
2121
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
2222
github.com/blevesearch/bleve/v2 v2.3.10
2323
github.com/bufbuild/connect-go v1.10.0
@@ -172,7 +172,7 @@ require (
172172
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
173173
github.com/davidmz/go-pageant v1.0.2 // indirect
174174
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
175-
github.com/dlclark/regexp2 v1.10.0 // indirect
175+
github.com/dlclark/regexp2 v1.11.0 // indirect
176176
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 // indirect
177177
github.com/fatih/color v1.16.0 // indirect
178178
github.com/felixge/httpsnoop v1.0.4 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06
104104
github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I=
105105
github.com/RoaringBitmap/roaring v1.7.0 h1:OZF303tJCER1Tj3x+aArx/S5X7hrT186ri6JjrGvG68=
106106
github.com/RoaringBitmap/roaring v1.7.0/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
107-
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
108-
github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
107+
github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
108+
github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
109109
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
110-
github.com/alecthomas/chroma/v2 v2.12.0 h1:Wh8qLEgMMsN7mgyG8/qIpegky2Hvzr4By6gEF7cmWgw=
111-
github.com/alecthomas/chroma/v2 v2.12.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
110+
github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
111+
github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
112112
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
113-
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
114-
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
113+
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
114+
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
115115
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA=
116116
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
117117
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
@@ -260,8 +260,8 @@ github.com/djherbis/nio/v3 v3.0.1/go.mod h1:Ng4h80pbZFMla1yKzm61cF0tqqilXZYrogmW
260260
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
261261
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
262262
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
263-
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
264-
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
263+
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
264+
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
265265
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
266266
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY=
267267
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s=

models/issues/label.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,17 @@ func (l *Label) CalOpenIssues() {
116116
func (l *Label) SetArchived(isArchived bool) {
117117
if !isArchived {
118118
l.ArchivedUnix = timeutil.TimeStamp(0)
119-
} else if isArchived && l.ArchivedUnix.IsZero() {
119+
} else if isArchived && !l.IsArchived() {
120120
// Only change the date when it is newly archived.
121121
l.ArchivedUnix = timeutil.TimeStampNow()
122122
}
123123
}
124124

125+
// IsArchived returns true if label is an archived
126+
func (l *Label) IsArchived() bool {
127+
return !l.ArchivedUnix.IsZero()
128+
}
129+
125130
// CalOpenOrgIssues calculates the open issues of a label for a specific repo
126131
func (l *Label) CalOpenOrgIssues(ctx context.Context, repoID, labelID int64) {
127132
counts, _ := CountIssuesByRepo(ctx, &IssuesOptions{
@@ -166,11 +171,6 @@ func (l *Label) BelongsToOrg() bool {
166171
return l.OrgID > 0
167172
}
168173

169-
// IsArchived returns true if label is an archived
170-
func (l *Label) IsArchived() bool {
171-
return l.ArchivedUnix > 0
172-
}
173-
174174
// BelongsToRepo returns true if label is a repository label
175175
func (l *Label) BelongsToRepo() bool {
176176
return l.RepoID > 0

modules/indexer/internal/bleve/query.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package bleve
55

66
import (
7+
"code.gitea.io/gitea/modules/optional"
8+
79
"github.com/blevesearch/bleve/v2"
810
"github.com/blevesearch/bleve/v2/search/query"
911
)
@@ -39,18 +41,18 @@ func BoolFieldQuery(value bool, field string) *query.BoolFieldQuery {
3941
return q
4042
}
4143

42-
func NumericRangeInclusiveQuery(min, max *int64, field string) *query.NumericRangeQuery {
44+
func NumericRangeInclusiveQuery(min, max optional.Option[int64], field string) *query.NumericRangeQuery {
4345
var minF, maxF *float64
4446
var minI, maxI *bool
45-
if min != nil {
47+
if min.Has() {
4648
minF = new(float64)
47-
*minF = float64(*min)
49+
*minF = float64(min.Value())
4850
minI = new(bool)
4951
*minI = true
5052
}
51-
if max != nil {
53+
if max.Has() {
5254
maxF = new(float64)
53-
*maxF = float64(*max)
55+
*maxF = float64(max.Value())
5456
maxI = new(bool)
5557
*maxI = true
5658
}

modules/indexer/issues/bleve/bleve.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -224,38 +224,41 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
224224
queries = append(queries, bleve.NewDisjunctionQuery(milestoneQueries...))
225225
}
226226

227-
if options.ProjectID != nil {
228-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ProjectID, "project_id"))
227+
if options.ProjectID.Has() {
228+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ProjectID.Value(), "project_id"))
229229
}
230-
if options.ProjectBoardID != nil {
231-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ProjectBoardID, "project_board_id"))
230+
if options.ProjectBoardID.Has() {
231+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ProjectBoardID.Value(), "project_board_id"))
232232
}
233233

234-
if options.PosterID != nil {
235-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.PosterID, "poster_id"))
234+
if options.PosterID.Has() {
235+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.PosterID.Value(), "poster_id"))
236236
}
237237

238-
if options.AssigneeID != nil {
239-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.AssigneeID, "assignee_id"))
238+
if options.AssigneeID.Has() {
239+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.AssigneeID.Value(), "assignee_id"))
240240
}
241241

242-
if options.MentionID != nil {
243-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.MentionID, "mention_ids"))
242+
if options.MentionID.Has() {
243+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.MentionID.Value(), "mention_ids"))
244244
}
245245

246-
if options.ReviewedID != nil {
247-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ReviewedID, "reviewed_ids"))
246+
if options.ReviewedID.Has() {
247+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ReviewedID.Value(), "reviewed_ids"))
248248
}
249-
if options.ReviewRequestedID != nil {
250-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.ReviewRequestedID, "review_requested_ids"))
249+
if options.ReviewRequestedID.Has() {
250+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.ReviewRequestedID.Value(), "review_requested_ids"))
251251
}
252252

253-
if options.SubscriberID != nil {
254-
queries = append(queries, inner_bleve.NumericEqualityQuery(*options.SubscriberID, "subscriber_ids"))
253+
if options.SubscriberID.Has() {
254+
queries = append(queries, inner_bleve.NumericEqualityQuery(options.SubscriberID.Value(), "subscriber_ids"))
255255
}
256256

257-
if options.UpdatedAfterUnix != nil || options.UpdatedBeforeUnix != nil {
258-
queries = append(queries, inner_bleve.NumericRangeInclusiveQuery(options.UpdatedAfterUnix, options.UpdatedBeforeUnix, "updated_unix"))
257+
if options.UpdatedAfterUnix.Has() || options.UpdatedBeforeUnix.Has() {
258+
queries = append(queries, inner_bleve.NumericRangeInclusiveQuery(
259+
options.UpdatedAfterUnix,
260+
options.UpdatedBeforeUnix,
261+
"updated_unix"))
259262
}
260263

261264
var indexerQuery query.Query = bleve.NewConjunctionQuery(queries...)

modules/indexer/issues/db/options.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@ import (
1515
)
1616

1717
func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_model.IssuesOptions, error) {
18-
// See the comment of issues_model.SearchOptions for the reason why we need to convert
19-
convertID := func(id *int64) int64 {
20-
if id == nil {
21-
return 0
22-
}
23-
if *id == 0 {
24-
return db.NoConditionID
25-
}
26-
return *id
27-
}
28-
convertInt64 := func(i *int64) int64 {
29-
if i == nil {
30-
return 0
31-
}
32-
return *i
33-
}
3418
var sortType string
3519
switch options.SortBy {
3620
case internal.SortByCreatedAsc:
@@ -53,6 +37,18 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
5337
sortType = "newest"
5438
}
5539

40+
// See the comment of issues_model.SearchOptions for the reason why we need to convert
41+
convertID := func(id optional.Option[int64]) int64 {
42+
if !id.Has() {
43+
return 0
44+
}
45+
value := id.Value()
46+
if value == 0 {
47+
return db.NoConditionID
48+
}
49+
return value
50+
}
51+
5652
opts := &issue_model.IssuesOptions{
5753
Paginator: options.Paginator,
5854
RepoIDs: options.RepoIDs,
@@ -73,8 +69,8 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
7369
IncludeMilestones: nil,
7470
SortType: sortType,
7571
IssueIDs: nil,
76-
UpdatedAfterUnix: convertInt64(options.UpdatedAfterUnix),
77-
UpdatedBeforeUnix: convertInt64(options.UpdatedBeforeUnix),
72+
UpdatedAfterUnix: options.UpdatedAfterUnix.Value(),
73+
UpdatedBeforeUnix: options.UpdatedBeforeUnix.Value(),
7874
PriorityRepoID: 0,
7975
IsArchived: optional.None[bool](),
8076
Org: nil,

modules/indexer/issues/dboptions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package issues
66
import (
77
"code.gitea.io/gitea/models/db"
88
issues_model "code.gitea.io/gitea/models/issues"
9+
"code.gitea.io/gitea/modules/optional"
910
)
1011

1112
func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOptions {
@@ -38,13 +39,12 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
3839
}
3940

4041
// See the comment of issues_model.SearchOptions for the reason why we need to convert
41-
convertID := func(id int64) *int64 {
42+
convertID := func(id int64) optional.Option[int64] {
4243
if id > 0 {
43-
return &id
44+
return optional.Some(id)
4445
}
4546
if id == db.NoConditionID {
46-
var zero int64
47-
return &zero
47+
return optional.None[int64]()
4848
}
4949
return nil
5050
}
@@ -59,10 +59,10 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
5959
searchOpt.SubscriberID = convertID(opts.SubscriberID)
6060

6161
if opts.UpdatedAfterUnix > 0 {
62-
searchOpt.UpdatedAfterUnix = &opts.UpdatedAfterUnix
62+
searchOpt.UpdatedAfterUnix = optional.Some(opts.UpdatedAfterUnix)
6363
}
6464
if opts.UpdatedBeforeUnix > 0 {
65-
searchOpt.UpdatedBeforeUnix = &opts.UpdatedBeforeUnix
65+
searchOpt.UpdatedBeforeUnix = optional.Some(opts.UpdatedBeforeUnix)
6666
}
6767

6868
searchOpt.Paginator = opts.Paginator

0 commit comments

Comments
 (0)