Skip to content

Commit bc51ab6

Browse files
committed
Merge remote-tracking branch 'origin/main' into deps-67
* origin/main: [skip ci] Updated translations via Crowdin Fix UI Spacing Errors in mirror settings (go-gitea#28990) Add htmx guidelines (go-gitea#28993) Some refactor for git http (go-gitea#28995) Fix an actions schedule bug (go-gitea#28942) Fix doc img path in profile readme (go-gitea#28994) Introduce htmx and use it to avoid full page load on `Subscribe` and `Follow` (go-gitea#28908) Fix joins in `db.Find(AndCount)` (go-gitea#28978) Update golang links to use https (go-gitea#28980) Fix google logo in security page (go-gitea#28982)
2 parents 9bae9ce + ab45f9e commit bc51ab6

36 files changed

+359
-830
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ See the [development setup instructions](https://docs.gitea.com/development/hack
110110

111111
### Backend
112112

113-
Go dependencies are managed using [Go Modules](https://golang.org/cmd/go/#hdr-Module_maintenance). \
113+
Go dependencies are managed using [Go Modules](https://go.dev/cmd/go/#hdr-Module_maintenance). \
114114
You can find more details in the [go mod documentation](https://go.dev/ref/mod) and the [Go Modules Wiki](https://github.com/golang/go/wiki/Modules).
115115

116116
Pull requests should only modify `go.mod` and `go.sum` where it is related to your change, be it a bugfix or a new feature. \

docs/content/administration/environment-variables.zh-cn.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ GITEA_CUSTOM=/home/gitea/custom ./gitea web
2929

3030
* `GOOS`
3131
* `GOARCH`
32-
* [`GOPATH`](https://golang.org/cmd/go/#hdr-GOPATH_environment_variable)
32+
* [`GOPATH`](https://go.dev/cmd/go/#hdr-GOPATH_environment_variable)
3333

34-
您可以在[官方文档](https://golang.org/cmd/go/#hdr-Environment_variables)中查阅这些配置参数的详细信息。
34+
您可以在[官方文档](https://go.dev/cmd/go/#hdr-Environment_variables)中查阅这些配置参数的详细信息。
3535

3636
## Gitea 的文件目录
3737

docs/content/administration/mail-templates.en-us.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Text and macros for the mail body
8585
Specifying a _subject_ section is optional (and therefore also the dash line separator). When used, the separator between
8686
_subject_ and _mail body_ templates requires at least three dashes; no other characters are allowed in the separator line.
8787

88-
_Subject_ and _mail body_ are parsed by [Golang's template engine](https://golang.org/pkg/text/template/) and
88+
_Subject_ and _mail body_ are parsed by [Golang's template engine](https://go.dev/pkg/text/template/) and
8989
are provided with a _metadata context_ assembled for each notification. The context contains the following elements:
9090

9191
| Name | Type | Available | Usage |
@@ -110,7 +110,7 @@ All names are case sensitive.
110110

111111
### The _subject_ part of the template
112112

113-
The template engine used for the mail _subject_ is golang's [`text/template`](https://golang.org/pkg/text/template/).
113+
The template engine used for the mail _subject_ is golang's [`text/template`](https://go.dev/pkg/text/template/).
114114
Please refer to the linked documentation for details about its syntax.
115115

116116
The _subject_ is built using the following steps:
@@ -138,15 +138,15 @@ the two templates, even if a valid subject template is present.
138138

139139
### The _mail body_ part of the template
140140

141-
The template engine used for the _mail body_ is golang's [`html/template`](https://golang.org/pkg/html/template/).
141+
The template engine used for the _mail body_ is golang's [`html/template`](https://go.dev/pkg/html/template/).
142142
Please refer to the linked documentation for details about its syntax.
143143

144144
The _mail body_ is parsed after the mail subject, so there is an additional _metadata_ field which is
145145
the actual rendered subject, after all considerations.
146146

147147
The expected result is HTML (including structural elements like`<html>`, `<body>`, etc.). Styling
148148
through `<style>` blocks, `class` and `style` attributes is possible. However, `html/template`
149-
does some [automatic escaping](https://golang.org/pkg/html/template/#hdr-Contexts) that should be considered.
149+
does some [automatic escaping](https://go.dev/pkg/html/template/#hdr-Contexts) that should be considered.
150150

151151
Attachments (such as images or external style sheets) are not supported. However, other templates can
152152
be referenced too, for example to provide the contents of a `<style>` element in a centralized fashion.

docs/content/administration/mail-templates.zh-cn.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ custom/templates/mail/pull/comment.tmpl
8181

8282
指定 _主题_ 部分是可选的(因此也是虚线分隔符)。在使用时,_主题__邮件正文_ 模板之间的分隔符需要至少三个虚线;分隔符行中不允许使用其他字符。
8383

84-
_主题__邮件正文_[Golang的模板引擎](https://golang.org/pkg/text/template/) 解析,并提供了为每个通知组装的 _元数据上下文_。上下文包含以下元素:
84+
_主题__邮件正文_[Golang的模板引擎](https://go.dev/pkg/text/template/) 解析,并提供了为每个通知组装的 _元数据上下文_。上下文包含以下元素:
8585

8686
| 名称 | 类型 | 可用性 | 用途 |
8787
| -------------------- | ------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -105,7 +105,7 @@ _主题_ 和 _邮件正文_ 由 [Golang的模板引擎](https://golang.org/pkg/t
105105

106106
### 模板中的主题部分
107107

108-
用于邮件主题的模板引擎是 Golang 的 [`text/template`](https://golang.org/pkg/text/template/)
108+
用于邮件主题的模板引擎是 Golang 的 [`text/template`](https://go.dev/pkg/text/template/)
109109
有关语法的详细信息,请参阅链接的文档。
110110

111111
主题构建的步骤如下:
@@ -130,12 +130,12 @@ _主题_ 和 _邮件正文_ 由 [Golang的模板引擎](https://golang.org/pkg/t
130130

131131
### 模板中的邮件正文部分
132132

133-
用于邮件正文的模板引擎是 Golang 的 [`html/template`](https://golang.org/pkg/html/template/)
133+
用于邮件正文的模板引擎是 Golang 的 [`html/template`](https://go.dev/pkg/html/template/)
134134
有关语法的详细信息,请参阅链接的文档。
135135

136136
邮件正文在邮件主题之后进行解析,因此还有一个额外的 _元数据_ 字段,即在考虑所有情况之后实际呈现的主题。
137137

138-
期望的结果是 HTML(包括结构元素,如`<html>``<body>`等)。可以通过 `<style>` 块、`class``style` 属性进行样式设置。但是,`html/template` 会进行一些 [自动转义](https://golang.org/pkg/html/template/#hdr-Contexts),需要考虑这一点。
138+
期望的结果是 HTML(包括结构元素,如`<html>``<body>`等)。可以通过 `<style>` 块、`class``style` 属性进行样式设置。但是,`html/template` 会进行一些 [自动转义](https://go.dev/pkg/html/template/#hdr-Contexts),需要考虑这一点。
139139

140140
不支持附件(例如图像或外部样式表)。但是,也可以引用其他模板,例如以集中方式提供 `<style>` 元素的内容。外部模板必须放置在 `custom/mail` 下,并相对于该目录引用。例如,可以使用 `{{template styles/base}}` 包含 `custom/mail/styles/base.tmpl`
141141

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

+3
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ Recommended implementations:
6565

6666
* Vue + Vanilla JS
6767
* Fomantic-UI (jQuery)
68+
* htmx (partial page reloads for otherwise static components)
6869
* Vanilla JS
6970

7071
Discouraged implementations:
7172

7273
* Vue + Fomantic-UI (jQuery)
7374
* jQuery + Vanilla JS
75+
* htmx + any other framework which requires heavy JS code, or unnecessary features like htmx scripting (`hx-on`)
7476

7577
To make UI consistent, Vue components can use Fomantic-UI CSS classes.
78+
We use htmx for simple interactions. You can see an example for simple interactions where htmx should be used in this [PR](https://github.com/go-gitea/gitea/pull/28908). Do not use htmx if you require more advanced reactivity, use another framework (Vue/Vanilla JS).
7679
Although mixing different frameworks is discouraged,
7780
it should also work if the mixing is necessary and the code is well-designed and maintainable.
7881

docs/content/development/hacking-on-gitea.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To get a quick working development environment you could use Gitpod.
2525

2626
## Installing go
2727

28-
You should [install go](https://golang.org/doc/install) and set up your go
28+
You should [install go](https://go.dev/doc/install) and set up your go
2929
environment correctly.
3030

3131
Next, [install Node.js with npm](https://nodejs.org/en/download/) which is

docs/content/development/hacking-on-gitea.zh-cn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ menu:
2525

2626
## 安装 Golang
2727

28-
您需要 [安装 go]( https://golang.org/doc/install ) 并设置您的 go 环境。
28+
您需要 [安装 go]( https://go.dev/doc/install ) 并设置您的 go 环境。
2929

3030
接下来,[使用 npm 安装 Node.js](https://nodejs.org/en/download/) ,这是构建
3131
JavaScript 和 CSS 文件的必要工具。最低支持的 Node.js 版本是 @minNodeVersion@

docs/content/installation/from-source.en-us.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ menu:
1717

1818
# Installation from source
1919

20-
You should [install go](https://golang.org/doc/install) and set up your go
20+
You should [install go](https://go.dev/doc/install) and set up your go
2121
environment correctly. In particular, it is recommended to set the `$GOPATH`
2222
environment variable and to add the go bin directory or directories
2323
`${GOPATH//://bin:}/bin` to the `$PATH`. See the Go wiki entry for
@@ -82,7 +82,7 @@ git checkout v@version@ # or git checkout pr-xyz
8282

8383
To build from source, the following programs must be present on the system:
8484

85-
- `go` @minGoVersion@ or higher, see [here](https://golang.org/dl/)
85+
- `go` @minGoVersion@ or higher, see [here](https://go.dev/dl/)
8686
- `node` @minNodeVersion@ or higher with `npm`, see [here](https://nodejs.org/en/download/)
8787
- `make`, see [here](development/hacking-on-gitea.md#installing-make)
8888

@@ -119,7 +119,7 @@ TAGS="bindata sqlite sqlite_unlock_notify" make build
119119

120120
The `build` target is split into two sub-targets:
121121

122-
- `make backend` which requires [Go @minGoVersion@](https://golang.org/dl/) or greater.
122+
- `make backend` which requires [Go @minGoVersion@](https://go.dev/dl/) or greater.
123123
- `make frontend` which requires [Node.js @minNodeVersion@](https://nodejs.org/en/download/) or greater.
124124

125125
If pre-built frontend files are present it is possible to only build the backend:
@@ -165,7 +165,7 @@ Running `gitea help` will allow you to review what the computed settings will be
165165

166166
## Cross Build
167167

168-
The `go` compiler toolchain supports cross-compiling to different architecture targets that are supported by the toolchain. See [`GOOS` and `GOARCH` environment variable](https://golang.org/doc/install/source#environment) for the list of supported targets. Cross compilation is helpful if you want to build Gitea for less-powerful systems (such as Raspberry Pi).
168+
The `go` compiler toolchain supports cross-compiling to different architecture targets that are supported by the toolchain. See [`GOOS` and `GOARCH` environment variable](https://go.dev/doc/install/source#environment) for the list of supported targets. Cross compilation is helpful if you want to build Gitea for less-powerful systems (such as Raspberry Pi).
169169

170170
To cross build Gitea with build tags (`TAGS`), you also need a C cross compiler which targets the same architecture as selected by the `GOOS` and `GOARCH` variables. For example, to cross build for Linux ARM64 (`GOOS=linux` and `GOARCH=arm64`), you need the `aarch64-unknown-linux-gnu-gcc` cross compiler. This is required because Gitea build tags uses `cgo`'s foreign-function interface (FFI).
171171

docs/content/installation/from-source.zh-cn.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ git checkout v@version@ # or git checkout pr-xyz
6262

6363
要从源代码进行构建,系统必须预先安装以下程序:
6464

65-
- `go` @minGoVersion@ 或更高版本,请参阅 [这里](https://golang.org/dl/)
65+
- `go` @minGoVersion@ 或更高版本,请参阅 [这里](https://go.dev/dl/)
6666
- `node` @minNodeVersion@ 或更高版本,并且安装 `npm`, 请参阅 [这里](https://nodejs.org/zh-cn/download/)
6767
- `make`, 请参阅 [这里](development/hacking-on-gitea.md)
6868

@@ -128,7 +128,7 @@ Gitea 将从`CustomPath`中查找许多信息。默认的,这会在运行 Gite
128128

129129
## 交叉编译
130130

131-
`go`编译器工具链支持将代码交叉编译到不同的目标架构上。请参考[`GOOS``GOARCH`环境变量](https://golang.org/doc/install/source#environment) 以获取支持的目标列表。如果您想为性能较弱的系统(如树莓派)构建 Gitea,交叉编译非常有用。
131+
`go`编译器工具链支持将代码交叉编译到不同的目标架构上。请参考[`GOOS``GOARCH`环境变量](https://go.dev/doc/install/source#environment) 以获取支持的目标列表。如果您想为性能较弱的系统(如树莓派)构建 Gitea,交叉编译非常有用。
132132

133133
要使用构建标签(`TAGS`)进行交叉编译Gitea,您还需要一个 C 交叉编译器,该编译器的目标架构与`GOOS``GOARCH`变量选择的架构相同。例如,要为 Linux ARM64(`GOOS=linux``GOARCH=arm64`)进行交叉编译,您需要`aarch64-unknown-linux-gnu-gcc`交叉编译器。这是因为 Gitea 构建标签使用了`cgo`的外部函数接口(FFI)。
134134

docs/content/usage/profile-readme.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ Making the `.profile` repository private will hide the Profile README.
2222

2323
Example of user with `.profile/README.md`:
2424

25-
![profile readme screenshot](./profile-readme.png)
25+
![profile readme screenshot](/images/usage/profile-readme.png)

models/db/list.go

+21-11
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,28 @@ type FindOptionsOrder interface {
133133

134134
// Find represents a common find function which accept an options interface
135135
func Find[T any](ctx context.Context, opts FindOptions) ([]*T, error) {
136-
sess := GetEngine(ctx)
136+
sess := GetEngine(ctx).Where(opts.ToConds())
137137

138-
if joinOpt, ok := opts.(FindOptionsJoin); ok && len(joinOpt.ToJoins()) > 0 {
138+
if joinOpt, ok := opts.(FindOptionsJoin); ok {
139139
for _, joinFunc := range joinOpt.ToJoins() {
140140
if err := joinFunc(sess); err != nil {
141141
return nil, err
142142
}
143143
}
144144
}
145+
if orderOpt, ok := opts.(FindOptionsOrder); ok {
146+
if order := orderOpt.ToOrders(); order != "" {
147+
sess.OrderBy(order)
148+
}
149+
}
145150

146-
sess = sess.Where(opts.ToConds())
147151
page, pageSize := opts.GetPage(), opts.GetPageSize()
148152
if !opts.IsListAll() && pageSize > 0 {
149153
if page == 0 {
150154
page = 1
151155
}
152156
sess.Limit(pageSize, (page-1)*pageSize)
153157
}
154-
if newOpt, ok := opts.(FindOptionsOrder); ok && newOpt.ToOrders() != "" {
155-
sess.OrderBy(newOpt.ToOrders())
156-
}
157158

158159
findPageSize := defaultFindSliceSize
159160
if pageSize > 0 {
@@ -168,8 +169,8 @@ func Find[T any](ctx context.Context, opts FindOptions) ([]*T, error) {
168169

169170
// Count represents a common count function which accept an options interface
170171
func Count[T any](ctx context.Context, opts FindOptions) (int64, error) {
171-
sess := GetEngine(ctx)
172-
if joinOpt, ok := opts.(FindOptionsJoin); ok && len(joinOpt.ToJoins()) > 0 {
172+
sess := GetEngine(ctx).Where(opts.ToConds())
173+
if joinOpt, ok := opts.(FindOptionsJoin); ok {
173174
for _, joinFunc := range joinOpt.ToJoins() {
174175
if err := joinFunc(sess); err != nil {
175176
return 0, err
@@ -178,7 +179,7 @@ func Count[T any](ctx context.Context, opts FindOptions) (int64, error) {
178179
}
179180

180181
var object T
181-
return sess.Where(opts.ToConds()).Count(&object)
182+
return sess.Count(&object)
182183
}
183184

184185
// FindAndCount represents a common findandcount function which accept an options interface
@@ -188,8 +189,17 @@ func FindAndCount[T any](ctx context.Context, opts FindOptions) ([]*T, int64, er
188189
if !opts.IsListAll() && pageSize > 0 && page >= 1 {
189190
sess.Limit(pageSize, (page-1)*pageSize)
190191
}
191-
if newOpt, ok := opts.(FindOptionsOrder); ok && newOpt.ToOrders() != "" {
192-
sess.OrderBy(newOpt.ToOrders())
192+
if joinOpt, ok := opts.(FindOptionsJoin); ok {
193+
for _, joinFunc := range joinOpt.ToJoins() {
194+
if err := joinFunc(sess); err != nil {
195+
return nil, 0, err
196+
}
197+
}
198+
}
199+
if orderOpt, ok := opts.(FindOptionsOrder); ok {
200+
if order := orderOpt.ToOrders(); order != "" {
201+
sess.OrderBy(order)
202+
}
193203
}
194204

195205
findPageSize := defaultFindSliceSize

modules/actions/workflows.go

+35
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,41 @@ func DetectWorkflows(
146146
return workflows, schedules, nil
147147
}
148148

149+
func DetectScheduledWorkflows(gitRepo *git.Repository, commit *git.Commit) ([]*DetectedWorkflow, error) {
150+
entries, err := ListWorkflows(commit)
151+
if err != nil {
152+
return nil, err
153+
}
154+
155+
wfs := make([]*DetectedWorkflow, 0, len(entries))
156+
for _, entry := range entries {
157+
content, err := GetContentFromEntry(entry)
158+
if err != nil {
159+
return nil, err
160+
}
161+
162+
// one workflow may have multiple events
163+
events, err := GetEventsFromContent(content)
164+
if err != nil {
165+
log.Warn("ignore invalid workflow %q: %v", entry.Name(), err)
166+
continue
167+
}
168+
for _, evt := range events {
169+
if evt.IsSchedule() {
170+
log.Trace("detect scheduled workflow: %q", entry.Name())
171+
dwf := &DetectedWorkflow{
172+
EntryName: entry.Name(),
173+
TriggerEvent: evt,
174+
Content: content,
175+
}
176+
wfs = append(wfs, dwf)
177+
}
178+
}
179+
}
180+
181+
return wfs, nil
182+
}
183+
149184
func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool {
150185
if !canGithubEventMatch(evt.Name, triggedEvent) {
151186
return false

options/locale/locale_en-US.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ app_desc = A painless, self-hosted Git service
186186
install = Easy to install
187187
install_desc = Simply <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/installation/install-from-binary">run the binary</a> for your platform, ship it with <a target="_blank" rel="noopener noreferrer" href="https://github.com/go-gitea/gitea/tree/master/docker">Docker</a>, or get it <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/installation/install-from-package">packaged</a>.
188188
platform = Cross-platform
189-
platform_desc = Gitea runs anywhere <a target="_blank" rel="noopener noreferrer" href="http://golang.org/">Go</a> can compile for: Windows, macOS, Linux, ARM, etc. Choose the one you love!
189+
platform_desc = Gitea runs anywhere <a target="_blank" rel="noopener noreferrer" href="https://go.dev/">Go</a> can compile for: Windows, macOS, Linux, ARM, etc. Choose the one you love!
190190
lightweight = Lightweight
191191
lightweight_desc = Gitea has low minimal requirements and can run on an inexpensive Raspberry Pi. Save your machine energy!
192192
license = Open Source
@@ -2013,6 +2013,7 @@ settings.mirror_settings.docs.doc_link_title = How do I mirror repositories?
20132013
settings.mirror_settings.docs.doc_link_pull_section = the "Pulling from a remote repository" section of the documentation.
20142014
settings.mirror_settings.docs.pulling_remote_title = Pulling from a remote repository
20152015
settings.mirror_settings.mirrored_repository = Mirrored repository
2016+
settings.mirror_settings.pushed_repository = Pushed repository
20162017
settings.mirror_settings.direction = Direction
20172018
settings.mirror_settings.direction.pull = Pull
20182019
settings.mirror_settings.direction.push = Push

0 commit comments

Comments
 (0)