Skip to content

Commit faefbf9

Browse files
committed
Merge branch 'main' of https://github.com/go-gitea/gitea into feature-swift
2 parents 367f8e1 + d74a7ef commit faefbf9

File tree

146 files changed

+2856
-1008
lines changed

Some content is hidden

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

146 files changed

+2856
-1008
lines changed

.drone.yml

Lines changed: 419 additions & 144 deletions
Large diffs are not rendered by default.

.stylelintrc.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
plugins:
22
- stylelint-declaration-strict-value
33

4+
ignoreFiles:
5+
- "**/*.go"
6+
47
overrides:
58
- files: ["**/*.less"]
69
customSyntax: postcss-less
710
- files: ["**/chroma/*", "**/codemirror/*", "**/standalone/*", "**/console/*"]
811
rules:
912
scale-unlimited/declaration-strict-value: null
13+
- files: ["**/chroma/*", "**/codemirror/*"]
14+
rules:
15+
block-no-empty: null
1016

1117
rules:
1218
alpha-value-notation: null

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ help:
190190
@echo " - deps install dependencies"
191191
@echo " - deps-frontend install frontend dependencies"
192192
@echo " - deps-backend install backend dependencies"
193+
@echo " - deps-tools install tool dependencies"
193194
@echo " - lint lint everything"
194195
@echo " - lint-frontend lint frontend files"
195196
@echo " - lint-backend lint backend files"
@@ -821,14 +822,17 @@ docs:
821822
cd docs; make trans-copy clean build-offline;
822823

823824
.PHONY: deps
824-
deps: deps-frontend deps-backend
825+
deps: deps-frontend deps-backend deps-tools
825826

826827
.PHONY: deps-frontend
827828
deps-frontend: node_modules
828829

829830
.PHONY: deps-backend
830831
deps-backend:
831832
$(GO) mod download
833+
834+
.PHONY: deps-tools
835+
deps-tools:
832836
$(GO) install $(AIR_PACKAGE)
833837
$(GO) install $(EDITORCONFIG_CHECKER_PACKAGE)
834838
$(GO) install $(ERRCHECK_PACKAGE)

cmd/admin.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cmd
77
import (
88
"errors"
99
"fmt"
10+
"net/url"
1011
"os"
1112
"strings"
1213
"text/tabwriter"
@@ -469,11 +470,19 @@ func runAddOauth(c *cli.Context) error {
469470
return err
470471
}
471472

473+
config := parseOAuth2Config(c)
474+
if config.Provider == "openidConnect" {
475+
discoveryURL, err := url.Parse(config.OpenIDConnectAutoDiscoveryURL)
476+
if err != nil || (discoveryURL.Scheme != "http" && discoveryURL.Scheme != "https") {
477+
return fmt.Errorf("invalid Auto Discovery URL: %s (this must be a valid URL starting with http:// or https://)", config.OpenIDConnectAutoDiscoveryURL)
478+
}
479+
}
480+
472481
return auth_model.CreateSource(&auth_model.Source{
473482
Type: auth_model.OAuth2,
474483
Name: c.String("name"),
475484
IsActive: true,
476-
Cfg: parseOAuth2Config(c),
485+
Cfg: config,
477486
})
478487
}
479488

cmd/dump.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func runDump(ctx *cli.Context) error {
250250

251251
if ctx.IsSet("skip-lfs-data") && ctx.Bool("skip-lfs-data") {
252252
log.Info("Skip dumping LFS data")
253-
} else if err := storage.LFS.IterateObjects(func(objPath string, object storage.Object) error {
253+
} else if err := storage.LFS.IterateObjects("", func(objPath string, object storage.Object) error {
254254
info, err := object.Stat()
255255
if err != nil {
256256
return err
@@ -351,7 +351,7 @@ func runDump(ctx *cli.Context) error {
351351

352352
if ctx.IsSet("skip-attachment-data") && ctx.Bool("skip-attachment-data") {
353353
log.Info("Skip dumping attachment data")
354-
} else if err := storage.Attachments.IterateObjects(func(objPath string, object storage.Object) error {
354+
} else if err := storage.Attachments.IterateObjects("", func(objPath string, object storage.Object) error {
355355
info, err := object.Stat()
356356
if err != nil {
357357
return err
@@ -364,7 +364,7 @@ func runDump(ctx *cli.Context) error {
364364

365365
if ctx.IsSet("skip-package-data") && ctx.Bool("skip-package-data") {
366366
log.Info("Skip dumping package data")
367-
} else if err := storage.Packages.IterateObjects(func(objPath string, object storage.Object) error {
367+
} else if err := storage.Packages.IterateObjects("", func(objPath string, object storage.Object) error {
368368
info, err := object.Stat()
369369
if err != nil {
370370
return err

contrib/init/ubuntu/gitea

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: gitea
4+
# Required-Start: $syslog $network
5+
# Required-Stop: $syslog
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop: 0 1 6
8+
# Short-Description: A self-hosted Git service written in Go.
9+
# Description: A self-hosted Git service written in Go.
10+
### END INIT INFO
11+
12+
# Do NOT "set -e"
13+
14+
# PATH should only include /usr/* if it runs after the mountnfs.sh script
15+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
16+
DESC="Gitea - Git with a cup of tea"
17+
NAME=gitea
18+
SERVICEVERBOSE=yes
19+
PIDFILE=/run/$NAME.pid
20+
SCRIPTNAME=/etc/init.d/$NAME
21+
WORKINGDIR=/var/lib/$NAME
22+
DAEMON=/usr/local/bin/$NAME
23+
DAEMON_ARGS="web -c /etc/$NAME/app.ini"
24+
USER=git
25+
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}"
26+
27+
# Read configuration variable file if it is present
28+
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
29+
30+
# Exit if the package is not installed
31+
[ -x "$DAEMON" ] || exit 0
32+
33+
do_start()
34+
{
35+
GITEA_ENVS="USER=$USER GITEA_WORK_DIR=$WORKINGDIR HOME=/home/$USER"
36+
GITEA_EXEC="$DAEMON -- $DAEMON_ARGS"
37+
sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
38+
--background --chdir $WORKINGDIR --chuid $USER \\
39+
--exec /bin/bash -- -c '/usr/bin/env $GITEA_ENVS $GITEA_EXEC'"
40+
}
41+
42+
do_stop()
43+
{
44+
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo
45+
rm -f $PIDFILE
46+
}
47+
48+
do_status()
49+
{
50+
if [ -f $PIDFILE ]; then
51+
if kill -0 $(cat "$PIDFILE"); then
52+
echo "$NAME is running, PID is $(cat $PIDFILE)"
53+
else
54+
echo "$NAME process is dead, but pidfile exists"
55+
fi
56+
else
57+
echo "$NAME is not running"
58+
fi
59+
}
60+
61+
case "$1" in
62+
start)
63+
echo "Starting $DESC" "$NAME"
64+
do_start
65+
;;
66+
stop)
67+
echo "Stopping $DESC" "$NAME"
68+
do_stop
69+
;;
70+
status)
71+
do_status
72+
;;
73+
restart)
74+
echo "Restarting $DESC" "$NAME"
75+
do_stop
76+
do_start
77+
;;
78+
*)
79+
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
80+
exit 2
81+
;;
82+
esac
83+
84+
exit 0

custom/conf/app.example.ini

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,22 @@ ROUTER = console
576576
;; The routing level will default to that of the system but individual router level can be set in
577577
;; [log.<mode>.router] LEVEL
578578
;;
579+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
580+
;;
581+
;; Print request id which parsed from request headers in access log, when access log is enabled.
582+
;; * E.g:
583+
;; * In request Header: X-Request-ID: test-id-123
584+
;; * Configuration in app.ini: REQUEST_ID_HEADERS = X-Request-ID
585+
;; * Print in log: 127.0.0.1:58384 - - [14/Feb/2023:16:33:51 +0800] "test-id-123"
586+
;;
587+
;; If you configure more than one in the .ini file, it will match in the order of configuration,
588+
;; and the first match will be finally printed in the log.
589+
;; * E.g:
590+
;; * In reuqest Header: X-Trace-ID: trace-id-1q2w3e4r
591+
;; * Configuration in app.ini: REQUEST_ID_HEADERS = X-Request-ID, X-Trace-ID, X-Req-ID
592+
;; * Print in log: 127.0.0.1:58384 - - [14/Feb/2023:16:33:51 +0800] "trace-id-1q2w3e4r"
593+
;;
594+
;; REQUEST_ID_HEADERS =
579595

580596
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
581597
;;
@@ -2256,6 +2272,17 @@ ROUTER = console
22562272
;PULL = 300
22572273
;GC = 60
22582274

2275+
2276+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2277+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2278+
;; Git Reflog timeout in days
2279+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2280+
;[git.reflog]
2281+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2282+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2283+
;ENABLED = true
2284+
;EXPIRATION = 90
2285+
22592286
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22602287
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22612288
;[mirror]

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,13 @@ Default templates for project boards:
881881
- `Identity`: the SignedUserName or `"-"` if not logged in.
882882
- `Start`: the start time of the request.
883883
- `ResponseWriter`: the responseWriter from the request.
884+
- `RequestID`: the value matching REQUEST_ID_HEADERS(default: `-`, if not matched).
884885
- You must be very careful to ensure that this template does not throw errors or panics as this template runs outside of the panic/recovery script.
886+
- `REQUEST_ID_HEADERS`: **\<empty\>**: You can configure multiple values that are splited by comma here. It will match in the order of configuration, and the first match will be finally printed in the access log.
887+
- e.g.
888+
- In the Request Header: X-Request-ID: **test-id-123**
889+
- Configuration in app.ini: REQUEST_ID_HEADERS = X-Request-ID
890+
- Print in log: 127.0.0.1:58384 - - [14/Feb/2023:16:33:51 +0800] "**test-id-123**" ...
885891

886892
### Log subsections (`log.name`, `log.name.*`)
887893

@@ -1087,6 +1093,11 @@ Default templates for project boards:
10871093
- `DISABLE_CORE_PROTECT_NTFS`: **false** Set to true to forcibly set `core.protectNTFS` to false.
10881094
- `DISABLE_PARTIAL_CLONE`: **false** Disable the usage of using partial clones for git.
10891095

1096+
## Git - Reflog settings (`git.reflog`)
1097+
1098+
- `ENABLED`: **true** Set to true to enable Git to write changes to reflogs in each repo.
1099+
- `EXPIRATION`: **90** Reflog entry lifetime, in days. Entries are removed opportunistically by Git.
1100+
10901101
## Git - Timeout settings (`git.timeout`)
10911102

10921103
- `DEFAULT`: **360**: Git operations default timeout seconds.

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,22 @@ test01.xls: application/vnd.ms-excel; charset=binary
262262

263263
- `ROOT_PATH`: 日志文件根目录。
264264
- `MODE`: 日志记录模式,默认是为 `console`。如果要写到多个通道,用逗号分隔
265-
- `LEVEL`: 日志级别,默认为`Trace`
265+
- `LEVEL`: 日志级别,默认为 `Trace`
266+
- `DISABLE_ROUTER_LOG`: 关闭日志中的路由日志。
267+
- `ENABLE_ACCESS_LOG`: 是否开启 Access Log, 默认为 false。
268+
- `ACCESS_LOG_TEMPLATE`: `access.log` 输出内容的模板,默认模板:**`{{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"`**
269+
模板支持以下参数:
270+
- `Ctx`: 请求上下文。
271+
- `Identity`: 登录用户名,默认: “`-`”。
272+
- `Start`: 请求开始时间。
273+
- `ResponseWriter`:
274+
- `RequestID`: 从请求头中解析得到的与 `REQUEST_ID_HEADERS` 匹配的值,默认: “`-`”。
275+
- 一定要谨慎配置该模板,否则可能会引起panic.
276+
- `REQUEST_ID_HEADERS`: 从 Request Header 中匹配指定 Key,并将匹配到的值输出到 `access.log` 中(需要在 `ACCESS_LOG_TEMPLATE` 中指定输出位置)。如果在该参数中配置多个 Key, 请用逗号分割,程序将按照配置的顺序进行匹配。
277+
- 示例:
278+
- 请求头: X-Request-ID: **test-id-123**
279+
- 配置文件: REQUEST_ID_HEADERS = X-Request-ID
280+
- 日志输出: 127.0.0.1:58384 - - [14/Feb/2023:16:33:51 +0800] "**test-id-123**" ...
266281

267282
## Cron (`cron`)
268283

docs/content/doc/developers/oauth2-provider.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Gitea supports the following scopes for tokens:
6060
| &nbsp;&nbsp;&nbsp; **write:public_key** | Grant read/write access to public keys |
6161
| &nbsp;&nbsp;&nbsp; **read:public_key** | Grant read-only access to public keys |
6262
| **admin:org_hook** | Grants full access to organizational-level hooks |
63+
| **admin:user_hook** | Grants full access to user-level hooks |
6364
| **notification** | Grants full access to notifications |
6465
| **user** | Grants full access to user profile info |
6566
| &nbsp;&nbsp;&nbsp; **read:user** | Grants read access to user's profile |

docs/content/doc/packages/maven.en-us.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Publish [Maven](https://maven.apache.org) packages for your user or organization
2323
## Requirements
2424

2525
To work with the Maven package registry, you can use [Maven](https://maven.apache.org/install.html) or [Gradle](https://gradle.org/install/).
26-
The following examples use `Maven`.
26+
The following examples use `Maven` and `Gradle Groovy`.
2727

2828
## Configuring the package registry
2929

@@ -73,6 +73,40 @@ Afterwards add the following sections to your project `pom.xml` file:
7373
| `access_token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}). |
7474
| `owner` | The owner of the package. |
7575

76+
### Gradle variant
77+
78+
When you plan to add some packages from Gitea instance in your project, you should add it in repositories section:
79+
80+
```groovy
81+
repositories {
82+
// other repositories
83+
maven { url "https://gitea.example.com/api/packages/{owner}/maven" }
84+
}
85+
```
86+
87+
In Groovy gradle you may include next script in your publishing part:
88+
89+
```groovy
90+
publishing {
91+
// other settings of publication
92+
repositories {
93+
maven {
94+
name = "Gitea"
95+
url = uri("https://gitea.example.com/api/packages/{owner}/maven")
96+
97+
credentials(HttpHeaderCredentials) {
98+
name = "Authorization"
99+
value = "token {access_token}"
100+
}
101+
102+
authentication {
103+
header(HttpHeaderAuthentication)
104+
}
105+
}
106+
}
107+
}
108+
```
109+
76110
## Publish a package
77111

78112
To publish a package simply run:
@@ -81,6 +115,12 @@ To publish a package simply run:
81115
mvn deploy
82116
```
83117

118+
Or call `gradle` with task `publishAllPublicationsToGiteaRepository` in case you are using gradle:
119+
120+
```groovy
121+
./gradlew publishAllPublicationsToGiteaRepository
122+
```
123+
84124
If you want to publish a prebuild package to the registry, you can use [`mvn deploy:deploy-file`](https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html):
85125

86126
```shell
@@ -105,6 +145,12 @@ To install a Maven package from the package registry, add a new dependency to yo
105145
</dependency>
106146
```
107147

148+
And analog in gradle groovy:
149+
150+
```groovy
151+
implementation "com.test.package:test_project:1.0.0"
152+
```
153+
108154
Afterwards run:
109155

110156
```shell

docs/content/doc/usage/labels.en-us.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ For repositories, labels can be created by going to `Issues` and clicking on `La
2323

2424
For organizations, you can define organization-wide labels that are shared with all organization repositories, including both already-existing repositories as well as newly created ones. Organization-wide labels can be created in the organization `Settings`.
2525

26-
Labels have a mandatory name, a mandatory color, an optional description, and must either be exclusive or not (see `Scoped labels` below).
26+
Labels have a mandatory name, a mandatory color, an optional description, and must either be exclusive or not (see `Scoped Labels` below).
2727

2828
When you create a repository, you can ensure certain labels exist by using the `Issue Labels` option. This option lists a number of available label sets that are [configured globally on your instance](../customizing-gitea/#labels). Its contained labels will all be created as well while creating the repository.
2929

3030
## Scoped Labels
3131

32-
A scoped label is a label that contains `/` in its name (not at either end of the name). For example labels `kind/bug` and `kind/enhancement` both have scope `kind`. Such labels will display the scope with slightly darker color.
32+
Scoped labels are used to ensure at most a single label with the same scope is assigned to an issue or pull request. For example, if labels `kind/bug` and `kind/enhancement` have the Exclusive option set, an issue can only be classified as a bug or an enhancement.
3333

34-
The scope of a label is determined based on the **last** `/`, so for example the scope of label `scope/subscope/item` is `scope/subscope`.
35-
36-
Scoped labels can be marked as exclusive. This ensures at most a single label with the same scope is assigned to an issue or pull request. For example, if `kind/bug` and `kind/enhancement` are marked exclusive, an issue can only be classified as a bug or an enhancement.
34+
A scoped label must contain `/` in its name (not at either end of the name). The scope of a label is determined based on the **last** `/`, so for example the scope of label `scope/subscope/item` is `scope/subscope`.
3735

3836
## Filtering by Label
3937

0 commit comments

Comments
 (0)