Skip to content

Commit d8ee8ac

Browse files
committed
Merge remote-tracking branch 'origin/main' into vitest-global
* origin/main: Fix dropdown icon position (go-gitea#27175) Fix repo sub menu (go-gitea#27169) Fix review request number and add more tests (go-gitea#27104) Fix the variable regexp pattern on web page (go-gitea#27161) Fix organization field being null in POST /orgs/{orgid}/teams (go-gitea#27150) Add index to `issue_user.issue_id` (go-gitea#27154) [skip ci] Updated translations via Crowdin Start development on Gitea 1.22 (go-gitea#27155) Fix successful return value for `SyncAndGetUserSpecificDiff` (go-gitea#27152) Improve actions docs related to `pull_request` event (go-gitea#27126) Remove outdated paragraphs when comparing Gitea Actions to GitHub Actions (go-gitea#27119) Fix: treat tab "overview" as "repositories" in user profiles without readme (go-gitea#27124) Fix incorrect test code for error handling (go-gitea#27139) Increase auth provider icon size on login page (go-gitea#27122) fix pagination for followers and following (go-gitea#27127) services/wiki: Close() after error handling (go-gitea#27129) Use fetch helpers instead of fetch (go-gitea#27026) Change green buttons to primary color (go-gitea#27099) Fix wrong xorm get usage on migration (go-gitea#27111)
2 parents 7285d9f + 1f026bc commit d8ee8ac

File tree

169 files changed

+498
-397
lines changed

Some content is hidden

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

169 files changed

+498
-397
lines changed

.eslintrc.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ overrides:
5050
- files: ["**/*.test.*", "web_src/js/test/setup.js"]
5151
env:
5252
vitest-globals/env: true
53+
- files: ["web_src/js/modules/fetch.js", "web_src/js/standalone/**/*"]
54+
rules:
55+
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]
5356

5457
rules:
5558
"@eslint-community/eslint-comments/disable-enable-pair": [2]
@@ -424,7 +427,7 @@ rules:
424427
no-restricted-exports: [0]
425428
no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, location, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, self, status, statusbar, stop, toolbar, top, __dirname, __filename]
426429
no-restricted-imports: [0]
427-
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]
430+
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression, {selector: "CallExpression[callee.name='fetch']", message: "use modules/fetch.js instead"}]
428431
no-return-assign: [0]
429432
no-script-url: [2]
430433
no-self-assign: [2, {props: true}]

docs/content/contributing/guidelines-frontend.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Some lint rules and IDEs also have warnings if the returned Promise is not handl
9595
### Fetching data
9696

9797
To fetch data, use the wrapper functions `GET`, `POST` etc. from `modules/fetch.js`. They
98-
accept a `data` option for the content, will automatically set CSFR token and return a
98+
accept a `data` option for the content, will automatically set CSRF token and return a
9999
Promise for a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response).
100100

101101
### HTML Attributes and `dataset`

docs/content/usage/actions/comparison.en-us.md

+9-13
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ As a workaround, you can use [go-hashfiles](https://gitea.com/actions/go-hashfil
9191

9292
## Missing features
9393

94-
### Variables
95-
96-
See [Variables](https://docs.github.com/en/actions/learn-github-actions/variables).
97-
98-
It's under development.
99-
10094
### Problem Matchers
10195

10296
Problem Matchers are a way to scan the output of actions for a specified regex pattern and surface that information prominently in the UI.
@@ -120,15 +114,17 @@ Pre and Post steps don't have their own section in the job log user interface.
120114

121115
### Downloading actions
122116

123-
Gitea Actions doesn't download actions from GitHub by default.
124-
"By default" means that you don't specify the host in the `uses` field, like `uses: actions/checkout@v3`.
125-
As a contrast, `uses: https://github.com/actions/checkout@v3` has specified host.
117+
Previously (Pre 1.21.0), `[actions].DEFAULT_ACTIONS_URL` defaulted to `https://gitea.com`.
118+
We have since restricted this option to only allow two values (`github` and `self`).
119+
When set to `github`, the new default, Gitea will download non-fully-qualified actions from <https://github.com>.
120+
For example, if you use `uses: actions/checkout@v3`, it will download the checkout repository from <https://github.com/actions/checkout.git>.
121+
122+
If you want to download an action from another git hoster, you can use an absolute URL, e.g. `uses: https://gitea.com/actions/checkout@v3`.
126123

127-
The missing host will be filled with `https://gitea.com` if you don't configure it.
128-
That means `uses: actions/checkout@v3` will download the action from [gitea.com/actions/checkout](https://gitea.com/actions/checkout), instead of [github.com/actions/checkout](https://github.com/actions/checkout).
124+
If your Gitea instance is in an intranet or a restricted area, you can set the URL to `self` to only download actions from your own instance by default.
125+
Of course, you can still use absolute URLs in workflows.
129126

130-
As mentioned, it's configurable.
131-
If you want your runners to download actions from GitHub or your own Gitea instance by default, you can configure it by setting `[actions].DEFAULT_ACTIONS_URL`. See [Configuration Cheat Sheet](administration/config-cheat-sheet.md#actions-actions).
127+
More details about the `[actions].DEFAULT_ACTIONS_URL` configuration can be found in the [Configuration Cheat Sheet](administration/config-cheat-sheet.md#actions-actions)
132128

133129
### Context availability
134130

docs/content/usage/actions/comparison.zh-cn.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,13 @@ Gitea Actions目前不支持此功能。
120120

121121
### 下载Actions
122122

123-
Gitea Actions默认不从GitHub下载Actions。
124-
"默认" 意味着您在`uses` 字段中不指定主机,如`uses: actions/checkout@v3`
125-
相反,`uses: https://github.com/actions/checkout@v3`是有指定主机的
123+
`[actions].DEFAULT_ACTIONS_URL` 保持默认值为 `github` 时,Gitea将会从 https://github.com 下载相对路径的actions。比如:
124+
如果你使用 `uses: actions/checkout@v3`,Gitea将会从 https://github.com/actions/checkout.git 下载这个 actions 项目
125+
如果你想要从另外一个 Git服务下载actions,你只需要使用绝对URL `uses: https://gitea.com/actions/checkout@v3` 来下载
126126

127-
如果您不进行配置,缺失的主机将填充为`https://gitea.com`
128-
这意味着`uses: actions/checkout@v3`将从[gitea.com/actions/checkout](https://gitea.com/actions/checkout)下载该Action,而不是[github.com/actions/checkout](https://github.com/actions/checkout)
127+
如果你的 Gitea 实例是部署在一个互联网限制的网络中,有可以使用绝对地址来下载 actions。你也可以讲配置项修改为 `[actions].DEFAULT_ACTIONS_URL = self`。这样所有的相对路径的actions引用,将不再会从 github.com 去下载,而会从这个 Gitea 实例自己的仓库中去下载。例如: `uses: actions/checkout@v3` 将会从 `[server].ROOT_URL`/actions/checkout.git 这个地址去下载 actions。
129128

130-
正如前面提到的,这是可配置的。
131-
如果您希望您的运行程序默认从GitHub或您自己的Gitea实例下载动作,您可以通过设置`[actions].DEFAULT_ACTIONS_URL`进行配置。请参阅[配置备忘单](administration/config-cheat-sheet.md#actions-actions)
129+
设置`[actions].DEFAULT_ACTIONS_URL`进行配置。请参阅[配置备忘单](administration/config-cheat-sheet.md#actions-actions)
132130

133131
### 上下文可用性
134132

docs/content/usage/actions/faq.en-us.md

+3
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,6 @@ For events supported only by GitHub, see GitHub's [documentation](https://docs.g
180180
| pull_request_review_comment | `created`, `edited` |
181181
| release | `published`, `edited` |
182182
| registry_package | `published` |
183+
184+
> For `pull_request` events, in [GitHub Actions](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request), the `ref` is `refs/pull/:prNumber/merge`, which is a reference to the merge commit preview. However, Gitea has no such reference.
185+
> Therefore, the `ref` in Gitea Actions is `refs/pull/:prNumber/head`, which points to the head of pull request rather than the preview of the merge commit.

docs/content/usage/actions/faq.zh-cn.md

+3
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,6 @@ defaults:
180180
| pull_request_review_comment | `created`, `edited` |
181181
| release | `published`, `edited` |
182182
| registry_package | `published` |
183+
184+
> 对于 `pull_request` 事件,在 [GitHub Actions](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) 中 `ref` 是 `refs/pull/:prNumber/merge`,它指向这个拉取请求合并提交的一个预览。但是 Gitea 没有这种 reference。
185+
> 因此,Gitea Actions 中 `ref` 是 `refs/pull/:prNumber/head`,它指向这个拉取请求的头分支而不是合并提交的预览。

models/fixtures/issue.yml

+17
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,20 @@
321321
created_unix: 946684830
322322
updated_unix: 978307200
323323
is_locked: false
324+
325+
-
326+
id: 20
327+
repo_id: 23
328+
index: 1
329+
poster_id: 2
330+
original_author_id: 0
331+
name: issue for pr
332+
content: content
333+
milestone_id: 0
334+
priority: 0
335+
is_closed: false
336+
is_pull: true
337+
num_comments: 0
338+
created_unix: 978307210
339+
updated_unix: 978307210
340+
is_locked: false

models/fixtures/pull_request.yml

+9
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,12 @@
8989
base_branch: main
9090
merge_base: cbff181af4c9c7fee3cf6c106699e07d9a3f54e6
9191
has_merged: false
92+
93+
-
94+
id: 8
95+
type: 0 # gitea pull request
96+
status: 2 # mergable
97+
issue_id: 20
98+
index: 1
99+
head_repo_id: 23
100+
base_repo_id: 23

models/fixtures/repository.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@
679679
num_forks: 0
680680
num_issues: 0
681681
num_closed_issues: 0
682-
num_pulls: 0
682+
num_pulls: 1
683683
num_closed_pulls: 0
684684
num_milestones: 0
685685
num_closed_milestones: 0

models/fixtures/review.yml

+38
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,41 @@
132132
content: "singular review from org6 and final review for this pr"
133133
updated_unix: 946684831
134134
created_unix: 946684831
135+
136+
-
137+
id: 16
138+
type: 4
139+
reviewer_id: 20
140+
issue_id: 20
141+
content: "review request for user20"
142+
updated_unix: 946684832
143+
created_unix: 946684832
144+
145+
-
146+
id: 17
147+
type: 1
148+
reviewer_id: 20
149+
issue_id: 20
150+
content: "review approved by user20"
151+
updated_unix: 946684833
152+
created_unix: 946684833
153+
-
154+
id: 18
155+
type: 4
156+
reviewer_id: 0
157+
reviewer_team_id: 5
158+
issue_id: 20
159+
content: "review request for team5"
160+
updated_unix: 946684834
161+
created_unix: 946684834
162+
163+
-
164+
id: 19
165+
type: 4
166+
reviewer_id: 15
167+
reviewer_team_id: 0
168+
issue_id: 20
169+
content: "review request for user15"
170+
updated_unix: 946684835
171+
created_unix: 946684835
172+

models/fixtures/team.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
name: review_team
9494
authorize: 1 # read
9595
num_repos: 1
96-
num_members: 2
96+
num_members: 3
9797
includes_all_repositories: false
9898
can_create_org_repo: false
9999

models/fixtures/team_user.yml

+6
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,9 @@
123123
org_id: 36
124124
team_id: 20
125125
uid: 5
126+
127+
-
128+
id: 22
129+
org_id: 17
130+
team_id: 9
131+
uid: 15

models/issues/issue_search.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,21 @@ func applyReviewRequestedCondition(sess *xorm.Session, reviewRequestedID int64)
362362
From("team_user").
363363
Where(builder.Eq{"team_user.uid": reviewRequestedID})
364364

365+
// if the review is approved or rejected, it should not be shown in the review requested list
366+
maxReview := builder.Select("MAX(r.id)").
367+
From("review as r").
368+
Where(builder.In("r.type", []ReviewType{ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest})).
369+
GroupBy("r.issue_id, r.reviewer_id, r.reviewer_team_id")
370+
365371
subQuery := builder.Select("review.issue_id").
366372
From("review").
367373
Where(builder.And(
368-
builder.In("review.type", []ReviewType{ReviewTypeRequest, ReviewTypeReject, ReviewTypeApprove}),
374+
builder.Eq{"review.type": ReviewTypeRequest},
369375
builder.Or(
370376
builder.Eq{"review.reviewer_id": reviewRequestedID},
371377
builder.In("review.reviewer_team_id", existInTeamQuery),
372378
),
379+
builder.In("review.id", maxReview),
373380
))
374381
return sess.Where("issue.poster_id <> ?", reviewRequestedID).
375382
And(builder.In("issue.id", subQuery))

models/issues/issue_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func TestCountIssues(t *testing.T) {
403403
assert.NoError(t, unittest.PrepareTestDatabase())
404404
count, err := issues_model.CountIssues(db.DefaultContext, &issues_model.IssuesOptions{})
405405
assert.NoError(t, err)
406-
assert.EqualValues(t, 19, count)
406+
assert.EqualValues(t, 20, count)
407407
}
408408

409409
func TestIssueLoadAttributes(t *testing.T) {

models/issues/issue_user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type IssueUser struct {
1616
ID int64 `xorm:"pk autoincr"`
1717
UID int64 `xorm:"INDEX"` // User ID.
18-
IssueID int64
18+
IssueID int64 `xorm:"INDEX"`
1919
IsRead bool
2020
IsMentioned bool
2121
}

models/migrations/migrations.go

+2
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ var migrations = []Migration{
534534
NewMigration("Add ScheduleID for ActionRun", v1_21.AddScheduleIDForActionRun),
535535
// v276 -> v277
536536
NewMigration("Add RemoteAddress to mirrors", v1_21.AddRemoteAddressToMirrors),
537+
// v277 -> v278
538+
NewMigration("Add Index to issue_user.issue_id", v1_21.AddIndexToIssueUserIssueID),
537539
}
538540

539541
// GetCurrentDBVersion returns the current db version

models/migrations/v1_21/v276.go

+14-19
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func migratePullMirrors(x *xorm.Engine) error {
4141
ID int64 `xorm:"pk autoincr"`
4242
RepoID int64 `xorm:"INDEX"`
4343
RemoteAddress string `xorm:"VARCHAR(2048)"`
44+
RepoOwner string
45+
RepoName string
4446
}
4547

4648
sess := x.NewSession()
@@ -59,7 +61,9 @@ func migratePullMirrors(x *xorm.Engine) error {
5961

6062
for {
6163
var mirrors []Mirror
62-
if err := sess.Limit(limit, start).Find(&mirrors); err != nil {
64+
if err := sess.Select("mirror.id, mirror.repo_id, mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name").
65+
Join("INNER", "repository", "repository.id = mirror.repo_id").
66+
Limit(limit, start).Find(&mirrors); err != nil {
6367
return err
6468
}
6569

@@ -69,7 +73,7 @@ func migratePullMirrors(x *xorm.Engine) error {
6973
start += len(mirrors)
7074

7175
for _, m := range mirrors {
72-
remoteAddress, err := getRemoteAddress(sess, m.RepoID, "origin")
76+
remoteAddress, err := getRemoteAddress(m.RepoOwner, m.RepoName, "origin")
7377
if err != nil {
7478
return err
7579
}
@@ -100,6 +104,8 @@ func migratePushMirrors(x *xorm.Engine) error {
100104
RepoID int64 `xorm:"INDEX"`
101105
RemoteName string
102106
RemoteAddress string `xorm:"VARCHAR(2048)"`
107+
RepoOwner string
108+
RepoName string
103109
}
104110

105111
sess := x.NewSession()
@@ -118,7 +124,9 @@ func migratePushMirrors(x *xorm.Engine) error {
118124

119125
for {
120126
var mirrors []PushMirror
121-
if err := sess.Limit(limit, start).Find(&mirrors); err != nil {
127+
if err := sess.Select("push_mirror.id, push_mirror.repo_id, push_mirror.remote_name, push_mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name").
128+
Join("INNER", "repository", "repository.id = push_mirror.repo_id").
129+
Limit(limit, start).Find(&mirrors); err != nil {
122130
return err
123131
}
124132

@@ -128,7 +136,7 @@ func migratePushMirrors(x *xorm.Engine) error {
128136
start += len(mirrors)
129137

130138
for _, m := range mirrors {
131-
remoteAddress, err := getRemoteAddress(sess, m.RepoID, m.RemoteName)
139+
remoteAddress, err := getRemoteAddress(m.RepoOwner, m.RepoName, m.RemoteName)
132140
if err != nil {
133141
return err
134142
}
@@ -153,25 +161,12 @@ func migratePushMirrors(x *xorm.Engine) error {
153161
return sess.Commit()
154162
}
155163

156-
func getRemoteAddress(sess *xorm.Session, repoID int64, remoteName string) (string, error) {
157-
var ownerName string
158-
var repoName string
159-
has, err := sess.
160-
Table("repository").
161-
Cols("owner_name", "lower_name").
162-
Where("id=?", repoID).
163-
Get(&ownerName, &repoName)
164-
if err != nil {
165-
return "", err
166-
} else if !has {
167-
return "", fmt.Errorf("repository [%v] not found", repoID)
168-
}
169-
164+
func getRemoteAddress(ownerName, repoName, remoteName string) (string, error) {
170165
repoPath := filepath.Join(setting.RepoRootPath, strings.ToLower(ownerName), strings.ToLower(repoName)+".git")
171166

172167
remoteURL, err := git.GetRemoteAddress(context.Background(), repoPath, remoteName)
173168
if err != nil {
174-
return "", err
169+
return "", fmt.Errorf("get remote %s's address of %s/%s failed: %v", remoteName, ownerName, repoName, err)
175170
}
176171

177172
u, err := giturl.Parse(remoteURL)

models/migrations/v1_21/v277.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_21 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
func AddIndexToIssueUserIssueID(x *xorm.Engine) error {
11+
type IssueUser struct {
12+
IssueID int64 `xorm:"INDEX"`
13+
}
14+
15+
return x.Sync(new(IssueUser))
16+
}

0 commit comments

Comments
 (0)