Skip to content

Commit 70f2fee

Browse files
authored
Merge branch 'main' into pubsub
2 parents d86c1dc + 83ba882 commit 70f2fee

File tree

111 files changed

+1363
-828
lines changed

Some content is hidden

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

111 files changed

+1363
-828
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/administration/mail-templates.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ clients don't even support HTML, so they show the text version included in the g
163163

164164
If the template fails to render, it will be noticed only at the moment the mail is sent.
165165
A default subject is used if the subject template fails, and whatever was rendered successfully
166-
from the the _mail body_ is used, disregarding the rest.
166+
from the _mail body_ is used, disregarding the rest.
167167

168168
Please check [Gitea's logs](administration/logging-config.md) for error messages in case of trouble.
169169

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
@@ -174,7 +174,7 @@ require (
174174
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
175175
github.com/davidmz/go-pageant v1.0.2 // indirect
176176
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
177-
github.com/dlclark/regexp2 v1.10.0 // indirect
177+
github.com/dlclark/regexp2 v1.11.0 // indirect
178178
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 // indirect
179179
github.com/fatih/color v1.16.0 // indirect
180180
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/activities/action.go

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ type Action struct {
148148
Repo *repo_model.Repository `xorm:"-"`
149149
CommentID int64 `xorm:"INDEX"`
150150
Comment *issues_model.Comment `xorm:"-"`
151+
Issue *issues_model.Issue `xorm:"-"` // get the issue id from content
151152
IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
152153
RefName string
153154
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
@@ -290,11 +291,6 @@ func (a *Action) GetRepoAbsoluteLink(ctx context.Context) string {
290291
return setting.AppURL + url.PathEscape(a.GetRepoUserName(ctx)) + "/" + url.PathEscape(a.GetRepoName(ctx))
291292
}
292293

293-
// GetCommentHTMLURL returns link to action comment.
294-
func (a *Action) GetCommentHTMLURL(ctx context.Context) string {
295-
return a.getCommentHTMLURL(ctx)
296-
}
297-
298294
func (a *Action) loadComment(ctx context.Context) (err error) {
299295
if a.CommentID == 0 || a.Comment != nil {
300296
return nil
@@ -303,69 +299,44 @@ func (a *Action) loadComment(ctx context.Context) (err error) {
303299
return err
304300
}
305301

306-
func (a *Action) getCommentHTMLURL(ctx context.Context) string {
302+
// GetCommentHTMLURL returns link to action comment.
303+
func (a *Action) GetCommentHTMLURL(ctx context.Context) string {
307304
if a == nil {
308305
return "#"
309306
}
310307
_ = a.loadComment(ctx)
311308
if a.Comment != nil {
312309
return a.Comment.HTMLURL(ctx)
313310
}
314-
if len(a.GetIssueInfos()) == 0 {
315-
return "#"
316-
}
317-
// Return link to issue
318-
issueIDString := a.GetIssueInfos()[0]
319-
issueID, err := strconv.ParseInt(issueIDString, 10, 64)
320-
if err != nil {
321-
return "#"
322-
}
323311

324-
issue, err := issues_model.GetIssueByID(ctx, issueID)
325-
if err != nil {
312+
if err := a.LoadIssue(ctx); err != nil || a.Issue == nil {
326313
return "#"
327314
}
328-
329-
if err = issue.LoadRepo(ctx); err != nil {
315+
if err := a.Issue.LoadRepo(ctx); err != nil {
330316
return "#"
331317
}
332318

333-
return issue.HTMLURL()
319+
return a.Issue.HTMLURL()
334320
}
335321

336322
// GetCommentLink returns link to action comment.
337323
func (a *Action) GetCommentLink(ctx context.Context) string {
338-
return a.getCommentLink(ctx)
339-
}
340-
341-
func (a *Action) getCommentLink(ctx context.Context) string {
342324
if a == nil {
343325
return "#"
344326
}
345327
_ = a.loadComment(ctx)
346328
if a.Comment != nil {
347329
return a.Comment.Link(ctx)
348330
}
349-
if len(a.GetIssueInfos()) == 0 {
350-
return "#"
351-
}
352-
// Return link to issue
353-
issueIDString := a.GetIssueInfos()[0]
354-
issueID, err := strconv.ParseInt(issueIDString, 10, 64)
355-
if err != nil {
356-
return "#"
357-
}
358331

359-
issue, err := issues_model.GetIssueByID(ctx, issueID)
360-
if err != nil {
332+
if err := a.LoadIssue(ctx); err != nil || a.Issue == nil {
361333
return "#"
362334
}
363-
364-
if err = issue.LoadRepo(ctx); err != nil {
335+
if err := a.Issue.LoadRepo(ctx); err != nil {
365336
return "#"
366337
}
367338

368-
return issue.Link()
339+
return a.Issue.Link()
369340
}
370341

371342
// GetBranch returns the action's repository branch.
@@ -393,6 +364,10 @@ func (a *Action) GetCreate() time.Time {
393364
return a.CreatedUnix.AsTime()
394365
}
395366

367+
func (a *Action) IsIssueEvent() bool {
368+
return a.OpType.InActions("comment_issue", "approve_pull_request", "reject_pull_request", "comment_pull", "merge_pull_request")
369+
}
370+
396371
// GetIssueInfos returns a list of associated information with the action.
397372
func (a *Action) GetIssueInfos() []string {
398373
// make sure it always returns 3 elements, because there are some access to the a[1] and a[2] without checking the length
@@ -403,27 +378,52 @@ func (a *Action) GetIssueInfos() []string {
403378
return ret
404379
}
405380

381+
func (a *Action) getIssueIndex() int64 {
382+
infos := a.GetIssueInfos()
383+
if len(infos) == 0 {
384+
return 0
385+
}
386+
index, _ := strconv.ParseInt(infos[0], 10, 64)
387+
return index
388+
}
389+
390+
func (a *Action) LoadIssue(ctx context.Context) error {
391+
if a.Issue != nil {
392+
return nil
393+
}
394+
if index := a.getIssueIndex(); index > 0 {
395+
issue, err := issues_model.GetIssueByIndex(ctx, a.RepoID, index)
396+
if err != nil {
397+
return err
398+
}
399+
a.Issue = issue
400+
a.Issue.Repo = a.Repo
401+
}
402+
return nil
403+
}
404+
406405
// GetIssueTitle returns the title of first issue associated with the action.
407406
func (a *Action) GetIssueTitle(ctx context.Context) string {
408-
index, _ := strconv.ParseInt(a.GetIssueInfos()[0], 10, 64)
409-
issue, err := issues_model.GetIssueByIndex(ctx, a.RepoID, index)
410-
if err != nil {
411-
log.Error("GetIssueByIndex: %v", err)
412-
return "500 when get issue"
407+
if err := a.LoadIssue(ctx); err != nil {
408+
log.Error("LoadIssue: %v", err)
409+
return "<500 when get issue>"
410+
}
411+
if a.Issue == nil {
412+
return "<Issue not found>"
413413
}
414-
return issue.Title
414+
return a.Issue.Title
415415
}
416416

417-
// GetIssueContent returns the content of first issue associated with
418-
// this action.
417+
// GetIssueContent returns the content of first issue associated with this action.
419418
func (a *Action) GetIssueContent(ctx context.Context) string {
420-
index, _ := strconv.ParseInt(a.GetIssueInfos()[0], 10, 64)
421-
issue, err := issues_model.GetIssueByIndex(ctx, a.RepoID, index)
422-
if err != nil {
423-
log.Error("GetIssueByIndex: %v", err)
424-
return "500 when get issue"
419+
if err := a.LoadIssue(ctx); err != nil {
420+
log.Error("LoadIssue: %v", err)
421+
return "<500 when get issue>"
422+
}
423+
if a.Issue == nil {
424+
return "<Content not found>"
425425
}
426-
return issue.Content
426+
return a.Issue.Content
427427
}
428428

429429
// GetFeedsOptions options for retrieving feeds
@@ -463,7 +463,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
463463
return nil, 0, fmt.Errorf("FindAndCount: %w", err)
464464
}
465465

466-
if err := ActionList(actions).loadAttributes(ctx); err != nil {
466+
if err := ActionList(actions).LoadAttributes(ctx); err != nil {
467467
return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
468468
}
469469

0 commit comments

Comments
 (0)