Skip to content

Commit de70352

Browse files
authored
Merge branch 'main' into fix-null-fields
2 parents 3688b8d + 1546580 commit de70352

File tree

444 files changed

+1811
-62346
lines changed

Some content is hidden

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

444 files changed

+1811
-62346
lines changed

.drone.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,11 +804,12 @@ steps:
804804
depends_on: [gpg-sign]
805805

806806
- name: github
807-
image: plugins/github-release:1
807+
image: plugins/github-release:latest
808808
pull: always
809809
settings:
810810
files:
811811
- "dist/release/*"
812+
file_exists: overwrite
812813
environment:
813814
GITHUB_TOKEN:
814815
from_secret: github_token

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ be reviewed by two maintainers and must pass the automatic tests.
423423
* And then push the tag as `git push origin v$vmaj.$vmin.$`. Drone CI will automatically create a release and upload all the compiled binary. (But currently it doesn't add the release notes automatically. Maybe we should fix that.)
424424
* If needed send a frontport PR for the changelog to branch `main` and update the version in `docs/config.yaml` to refer to the new version.
425425
* Send PR to [blog repository](https://gitea.com/gitea/blog) announcing the release.
426+
* Verify all release assets were correctly published through CI on dl.gitea.io and GitHub releases. Once ACKed:
427+
* bump the version of https://dl.gitea.io/gitea/version.json
428+
* merge the blog post PR
429+
* announce the release in discord `#announcements`
426430

427431
## Copyright
428432

cmd/admin.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ var (
5656
microcmdUserList,
5757
microcmdUserChangePassword,
5858
microcmdUserDelete,
59+
microcmdUserGenerateAccessToken,
5960
},
6061
}
6162

@@ -154,6 +155,27 @@ var (
154155
Action: runDeleteUser,
155156
}
156157

158+
microcmdUserGenerateAccessToken = cli.Command{
159+
Name: "generate-access-token",
160+
Usage: "Generate a access token for a specific user",
161+
Flags: []cli.Flag{
162+
cli.StringFlag{
163+
Name: "username,u",
164+
Usage: "Username",
165+
},
166+
cli.StringFlag{
167+
Name: "token-name,t",
168+
Usage: "Token name",
169+
Value: "gitea-admin",
170+
},
171+
cli.BoolFlag{
172+
Name: "raw",
173+
Usage: "Display only the token value",
174+
},
175+
},
176+
Action: runGenerateAccessToken,
177+
}
178+
157179
subcmdRepoSyncReleases = cli.Command{
158180
Name: "repo-sync-releases",
159181
Usage: "Synchronize repository releases with tags",
@@ -641,6 +663,41 @@ func runDeleteUser(c *cli.Context) error {
641663
return user_service.DeleteUser(user)
642664
}
643665

666+
func runGenerateAccessToken(c *cli.Context) error {
667+
if !c.IsSet("username") {
668+
return fmt.Errorf("You must provide the username to generate a token for them")
669+
}
670+
671+
ctx, cancel := installSignals()
672+
defer cancel()
673+
674+
if err := initDB(ctx); err != nil {
675+
return err
676+
}
677+
678+
user, err := user_model.GetUserByName(c.String("username"))
679+
if err != nil {
680+
return err
681+
}
682+
683+
t := &models.AccessToken{
684+
Name: c.String("token-name"),
685+
UID: user.ID,
686+
}
687+
688+
if err := models.NewAccessToken(t); err != nil {
689+
return err
690+
}
691+
692+
if c.Bool("raw") {
693+
fmt.Printf("%s\n", t.Token)
694+
} else {
695+
fmt.Printf("Access token was successfully created: %s\n", t.Token)
696+
}
697+
698+
return nil
699+
}
700+
644701
func runRepoSyncReleases(_ *cli.Context) error {
645702
ctx, cancel := installSignals()
646703
defer cancel()

contrib/update_dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ grep 'git' go.mod | grep '\.com' | grep -v indirect | grep -v replace | cut -f 2
44
go get -u "$line"
55
make vendor
66
git add .
7-
git commit -S -m "update $line"
7+
git commit -m "update $line"
88
done

custom/conf/app.example.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ PATH =
890890
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
891891
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
892892
;;
893-
;; Path for local repository copy. Defaults to `tmp/local-repo`
893+
;; Path for local repository copy. Defaults to `tmp/local-repo` (content gets deleted on gitea restart)
894894
;LOCAL_COPY_PATH = tmp/local-repo
895895

896896
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -902,7 +902,7 @@ PATH =
902902
;; Whether repository file uploads are enabled. Defaults to `true`
903903
;ENABLED = true
904904
;;
905-
;; Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gitea restart)
905+
;; Path for uploads. Defaults to `data/tmp/uploads` (content gets deleted on gitea restart)
906906
;TEMP_PATH = data/tmp/uploads
907907
;;
908908
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
@@ -2125,6 +2125,8 @@ PATH =
21252125
;RENDER_COMMAND = "asciidoc --out-file=- -"
21262126
;; Don't pass the file on STDIN, pass the filename as argument instead.
21272127
;IS_INPUT_FILE = false
2128+
; Don't filter html tags and attributes if true
2129+
;DISABLE_SANITIZER = false
21282130

21292131
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21302132
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ params:
1818
description: Git with a cup of tea
1919
author: The Gitea Authors
2020
website: https://docs.gitea.io
21-
version: 1.16.0
21+
version: 1.16.3
2222
minGoVersion: 1.16
2323
goVersion: 1.17
2424
minNodeVersion: 12.17

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
107107
### Repository - Upload (`repository.upload`)
108108

109109
- `ENABLED`: **true**: Whether repository file uploads are enabled
110-
- `TEMP_PATH`: **data/tmp/uploads**: Path for uploads (tmp gets deleted on Gitea restart)
110+
- `TEMP_PATH`: **data/tmp/uploads**: Path for uploads (content gets deleted on Gitea restart)
111111
- `ALLOWED_TYPES`: **\<empty\>**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
112112
- `FILE_MAX_SIZE`: **3**: Max size of each file in megabytes.
113113
- `MAX_FILES`: **5**: Max number of files per upload
@@ -144,7 +144,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
144144

145145
## Repository - Local (`repository.local`)
146146

147-
- `LOCAL_COPY_PATH`: **tmp/local-repo**: Path for temporary local repository copies. Defaults to `tmp/local-repo`
147+
- `LOCAL_COPY_PATH`: **tmp/local-repo**: Path for temporary local repository copies. Defaults to `tmp/local-repo` (content gets deleted on Gitea restart)
148148

149149
## Repository - MIME type mapping (`repository.mimetype_mapping`)
150150

@@ -1003,13 +1003,13 @@ IS_INPUT_FILE = false
10031003
command. Multiple extensions needs a comma as splitter.
10041004
- RENDER\_COMMAND: External command to render all matching extensions.
10051005
- IS\_INPUT\_FILE: **false** Input is not a standard input but a file param followed `RENDER_COMMAND`.
1006+
- DISABLE_SANITIZER: **false** Don't filter html tags and attributes if true. Don't change this to true except you know what that means.
10061007

10071008
Two special environment variables are passed to the render command:
10081009
- `GITEA_PREFIX_SRC`, which contains the current URL prefix in the `src` path tree. To be used as prefix for links.
10091010
- `GITEA_PREFIX_RAW`, which contains the current URL prefix in the `raw` path tree. To be used as prefix for image paths.
10101011

1011-
1012-
Gitea supports customizing the sanitization policy for rendered HTML. The example below will support KaTeX output from pandoc.
1012+
If `DISABLE_SANITIZER` is false, Gitea supports customizing the sanitization policy for rendered HTML. The example below will support KaTeX output from pandoc.
10131013

10141014
```ini
10151015
[markup.sanitizer.TeX]

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,33 @@ IS_INPUT_FILE = false
318318
- FILE_EXTENSIONS: 关联的文档的扩展名,多个扩展名用都好分隔。
319319
- RENDER_COMMAND: 工具的命令行命令及参数。
320320
- IS_INPUT_FILE: 输入方式是最后一个参数为文件路径还是从标准输入读取。
321+
- DISABLE_SANITIZER: **false** 如果为 true 则不过滤 HTML 标签和属性。除非你知道这意味着什么,否则不要设置为 true。
322+
323+
以下两个环境变量将会被传递给渲染命令:
324+
325+
- `GITEA_PREFIX_SRC`:包含当前的`src`路径的URL前缀,可以被用于链接的前缀。
326+
- `GITEA_PREFIX_RAW`:包含当前的`raw`路径的URL前缀,可以被用于图片的前缀。
327+
328+
如果 `DISABLE_SANITIZER` 为 false,则 Gitea 支持自定义渲染 HTML 的净化策略。以下例子将用 pandoc 支持 KaTeX 输出。
329+
330+
```ini
331+
[markup.sanitizer.TeX]
332+
; Pandoc renders TeX segments as <span>s with the "math" class, optionally
333+
; with "inline" or "display" classes depending on context.
334+
ELEMENT = span
335+
ALLOW_ATTR = class
336+
REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+
337+
ALLOW_DATA_URI_IMAGES = true
338+
```
339+
340+
- `ELEMENT`: 将要被应用到该策略的 HTML 元素,不能为空。
341+
- `ALLOW_ATTR`: 将要被应用到该策略的属性,不能为空。
342+
- `REGEXP`: 正则表达式,用来匹配属性的内容。如果为空,则跟属性内容无关。
343+
- `ALLOW_DATA_URI_IMAGES`: **false** 允许 data uri 图片 (`<img src="data:image/png;base64,..."/>`)。
344+
345+
多个净化规则可以被同时定义,只要section名称最后一位不重复即可。如: `[markup.sanitizer.TeX-2]`
346+
为了针对一种渲染类型进行一个特殊的净化策略,必须使用形如 `[markup.sanitizer.asciidoc.rule-1]` 的方式来命名 seciton。
347+
如果此规则没有匹配到任何渲染类型,它将会被应用到所有的渲染类型。
321348

322349
## Time (`time`)
323350

docs/content/doc/usage/backup-and-restore.en-us.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,59 @@ Repository Git Hooks should be regenerated if installation method is changed (eg
9595
With Gitea running, and from the directory Gitea's binary is located, execute: `./gitea admin regenerate hooks`
9696

9797
This ensures that application and configuration file paths in repository Git Hooks are consistent and applicable to the current installation. If these paths are not updated, repository `push` actions will fail.
98+
99+
### Using Docker (`restore`)
100+
101+
There is also no support for a recovery command in a Docker-based gitea instance. The restore process contains the same steps as described in the previous section but with different paths.
102+
103+
Example:
104+
105+
```sh
106+
# open bash session in container
107+
docker exec --user git -it 2a83b293548e bash
108+
# unzip your backup file within the container
109+
unzip gitea-dump-1610949662.zip
110+
cd gitea-dump-1610949662
111+
# restore the gitea data
112+
mv data/* /data/gitea
113+
# restore the repositories itself
114+
mv repos/* /data/git/repositories/
115+
# adjust file permissions
116+
chown -R git:git /data
117+
# Regenerate Git Hooks
118+
/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks
119+
```
120+
121+
The default user in the gitea container is `git` (1000:1000). Please replace `2a83b293548e` with your gitea container id or name.
122+
123+
These are the default paths used in the container:
124+
125+
```text
126+
DEFAULT CONFIGURATION:
127+
CustomPath: /data/gitea (GITEA_CUSTOM)
128+
CustomConf: /data/gitea/conf/app.ini
129+
AppPath: /usr/local/bin/gitea
130+
AppWorkPath: /usr/local/bin
131+
```
132+
133+
### Using Docker-rootless (`restore`)
134+
135+
The restore workflow in Docker-rootless containers differs only in the directories to be used:
136+
137+
```sh
138+
# open bash session in container
139+
docker exec --user git -it 2a83b293548e bash
140+
# unzip your backup file within the container
141+
unzip gitea-dump-1610949662.zip
142+
cd gitea-dump-1610949662
143+
# restore the app.ini
144+
mv data/conf/app.ini /etc/gitea/app.ini
145+
# restore the gitea data
146+
mv data/* /var/lib/gitea
147+
# restore the repositories itself
148+
mv repos/* /var/lib/gitea/git/repositories
149+
# adjust file permissions
150+
chown -R git:git /etc/gitea/app.ini /var/lib/gitea
151+
# Regenerate Git Hooks
152+
/usr/local/bin/gitea -c '/etc/gitea/app.ini' admin regenerate hooks
153+
```

docs/content/doc/usage/reverse-proxies.en-us.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ server {
3030
3131
location / {
3232
proxy_pass http://localhost:3000;
33+
proxy_set_header Host $host;
34+
proxy_set_header X-Real-IP $remote_addr;
35+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
36+
proxy_set_header X-Forwarded-Proto $scheme;
3337
}
3438
}
3539
```
@@ -47,6 +51,10 @@ server {
4751
location /git/ {
4852
# Note: Trailing slash
4953
proxy_pass http://localhost:3000/;
54+
proxy_set_header Host $host;
55+
proxy_set_header X-Real-IP $remote_addr;
56+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
57+
proxy_set_header X-Forwarded-Proto $scheme;
5058
}
5159
}
5260
```

0 commit comments

Comments
 (0)