Skip to content

Commit add8afe

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: 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) Fix the incorrect route path in the user edit page. (go-gitea#27007) Refactor lfs requests (go-gitea#26783) Display archived labels specially when listing labels (go-gitea#26820) Remove a `gt-float-right` and some unnecessary helpers (go-gitea#27110) [skip ci] Updated licenses and gitignores Fix token endpoints ignore specified account (go-gitea#27080) Make SSPI auth mockable (go-gitea#27036)
2 parents af87ff0 + 9336286 commit add8afe

File tree

170 files changed

+800
-630
lines changed

Some content is hidden

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

170 files changed

+800
-630
lines changed

.eslintrc.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ overrides:
4646
- files: ["*.config.*"]
4747
rules:
4848
import/no-unused-modules: [0]
49+
- files: ["web_src/js/modules/fetch.js", "web_src/js/standalone/**/*"]
50+
rules:
51+
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]
4952

5053
rules:
5154
"@eslint-community/eslint-comments/disable-enable-pair": [2]
@@ -420,7 +423,7 @@ rules:
420423
no-restricted-exports: [0]
421424
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]
422425
no-restricted-imports: [0]
423-
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]
426+
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression, {selector: "CallExpression[callee.name='fetch']", message: "use modules/fetch.js instead"}]
424427
no-return-assign: [0]
425428
no-script-url: [2]
426429
no-self-assign: [2, {props: true}]

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 9 additions & 13 deletions
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

Lines changed: 5 additions & 7 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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/migrations/v1_21/v276.go

Lines changed: 14 additions & 19 deletions
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)

modules/lfs/filesystem_client.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
// FilesystemClient is used to read LFS data from a filesystem path
1717
type FilesystemClient struct {
18-
lfsdir string
18+
lfsDir string
1919
}
2020

2121
// BatchSize returns the preferred size of batchs to process
@@ -25,16 +25,12 @@ func (c *FilesystemClient) BatchSize() int {
2525

2626
func newFilesystemClient(endpoint *url.URL) *FilesystemClient {
2727
path, _ := util.FileURLToPath(endpoint)
28-
29-
lfsdir := filepath.Join(path, "lfs", "objects")
30-
31-
client := &FilesystemClient{lfsdir}
32-
33-
return client
28+
lfsDir := filepath.Join(path, "lfs", "objects")
29+
return &FilesystemClient{lfsDir}
3430
}
3531

3632
func (c *FilesystemClient) objectPath(oid string) string {
37-
return filepath.Join(c.lfsdir, oid[0:2], oid[2:4], oid)
33+
return filepath.Join(c.lfsDir, oid[0:2], oid[2:4], oid)
3834
}
3935

4036
// Download reads the specific LFS object from the target path

0 commit comments

Comments
 (0)