Skip to content

Commit d6ed2b5

Browse files
authored
Merge branch 'main' into peterson/reflogs
2 parents 0e5bae2 + f521e88 commit d6ed2b5

File tree

264 files changed

+4676
-1947
lines changed

Some content is hidden

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

264 files changed

+4676
-1947
lines changed

Diff for: .drone.yml

+419-144
Large diffs are not rendered by default.

Diff for: .stylelintrc.yaml

+6
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

Diff for: CODE_OF_CONDUCT.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Gitea Community Code of Conduct
2+
3+
## About
4+
5+
Online communities include people from many different backgrounds. The Gitea contributors are committed to providing a friendly, safe and welcoming environment for all, regardless of gender identity and expression, sexual orientation, disabilities, neurodiversity, physical appearance, body size, ethnicity, nationality, race, age, religion, or similar personal characteristics.
6+
7+
The first goal of the Code of Conduct is to specify a baseline standard of behavior so that people with different social values and communication styles can talk about Gitea effectively, productively, and respectfully.
8+
9+
The second goal is to provide a mechanism for resolving conflicts in the community when they arise.
10+
11+
The third goal of the Code of Conduct is to make our community welcoming to people from different backgrounds. Diversity is critical to the project; for Gitea to be successful, it needs contributors and users from all backgrounds.
12+
13+
We believe that healthy debate and disagreement are essential to a healthy project and community. However, it is never ok to be disrespectful. We value diverse opinions, but we value respectful behavior more.
14+
15+
## Community values
16+
17+
These are the values to which people in the Gitea community should aspire.
18+
19+
- **Be friendly and welcoming.**
20+
- **Be patient.**
21+
- Remember that people have varying communication styles and that not everyone is using their native language. (Meaning and tone can be lost in translation.)
22+
- **Be thoughtful.**
23+
- Productive communication requires effort. Think about how your words will be interpreted.
24+
- Remember that sometimes it is best to refrain entirely from commenting.
25+
- **Be respectful.**
26+
- In particular, respect differences of opinion.
27+
- **Be charitable.**
28+
- Interpret the arguments of others in good faith, do not seek to disagree.
29+
- When we do disagree, try to understand why.
30+
- **Be constructive.**
31+
- Avoid derailing: stay on topic; if you want to talk about something else, start a new conversation.
32+
- Avoid unconstructive criticism: don't merely decry the current state of affairs; offer—or at least solicit—suggestions as to how things may be improved.
33+
- Avoid snarking (pithy, unproductive, sniping comments)
34+
- Avoid discussing potentially offensive or sensitive issues; this all too often leads to unnecessary conflict.
35+
- Avoid microaggressions (brief and commonplace verbal, behavioral and environmental indignities that communicate hostile, derogatory or negative slights and insults to a person or group).
36+
- **Be responsible.**
37+
- What you say and do matters. Take responsibility for your words and actions, including their consequences, whether intended or otherwise.
38+
39+
People are complicated. You should expect to be misunderstood and to misunderstand others; when this inevitably occurs, resist the urge to be defensive or assign blame. Try not to take offense where no offense was intended. Give people the benefit of the doubt. Even if the intent was to provoke, do not rise to it. It is the responsibility of all parties to de-escalate conflict when it arises.
40+
41+
## Code of Conduct
42+
43+
### Our Pledge
44+
45+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
46+
47+
### Our Standards
48+
49+
Examples of behavior that contributes to creating a positive environment include:
50+
51+
- Using welcoming and inclusive language
52+
- Being respectful of differing viewpoints and experiences
53+
- Gracefully accepting constructive criticism
54+
- Focusing on what is best for the community
55+
- Showing empathy towards other community members
56+
57+
Examples of unacceptable behavior by participants include:
58+
59+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
60+
- Trolling, insulting/derogatory comments, and personal or political attacks
61+
- Public or private harassment
62+
- Publishing others’ private information, such as a physical or electronic address, without explicit permission
63+
- Other conduct which could reasonably be considered inappropriate in a professional setting
64+
65+
### Our Responsibilities
66+
67+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
68+
69+
Project maintainers have the right and responsibility to remove, edit, or reject: comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, as well as to ban (temporarily or permanently) any contributor for behaviors that they deem inappropriate, threatening, offensive, or harmful.
70+
71+
### Scope
72+
73+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
74+
75+
This Code of Conduct also applies outside the project spaces when the Project Stewards have a reasonable belief that an individual’s behavior may have a negative impact on the project or its community.
76+
77+
### Conflict Resolution
78+
79+
We do not believe that all conflict is bad; healthy debate and disagreement often yield positive results. However, it is never okay to be disrespectful or to engage in behavior that violates the project’s code of conduct.
80+
81+
If you see someone violating the code of conduct, you are encouraged to address the behavior directly with those involved. Many issues can be resolved quickly and easily, and this gives people more control over the outcome of their dispute. If you are unable to resolve the matter for any reason, or if the behavior is threatening or harassing, report it. We are dedicated to providing an environment where participants feel welcome and safe.
82+
83+
Reports should be directed to the Gitea Project Stewards at [email protected]. It is the Project Stewards’ duty to receive and address reported violations of the code of conduct. They will then work with a committee consisting of representatives from the technical-oversight-committee.
84+
85+
We will investigate every complaint, but you may not receive a direct response. We will use our discretion in determining when and how to follow up on reported incidents, which may range from not taking action to permanent expulsion from the project and project-sponsored spaces. Under normal circumstances, we will notify the accused of the report and provide them an opportunity to discuss it before any action is taken. If there is a consensus between maintainers that such an endeavor would be useless (i.e. in case of an obvious spammer), we reserve the right to take action without notifying the accused first. The identity of the reporter will be omitted from the details of the report supplied to the accused. In potentially harmful situations, such as ongoing harassment or threats to anyone’s safety, we may take action without notice.
86+
87+
### Attribution
88+
89+
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
90+
91+
## Summary
92+
93+
- Treat everyone with respect and kindness.
94+
- Be thoughtful in how you communicate.
95+
- Don’t be destructive or inflammatory.
96+
- If you encounter an issue, please mail [email protected].

Diff for: Makefile

+5-1
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)

Diff for: cmd/admin.go

+10-1
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

Diff for: cmd/convert.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func runConvert(ctx *cli.Context) error {
3535
log.Info("Log path: %s", setting.Log.RootPath)
3636
log.Info("Configuration file: %s", setting.CustomConf)
3737

38-
if !setting.Database.UseMySQL {
38+
if !setting.Database.Type.IsMySQL() {
3939
fmt.Println("This command can only be used with a MySQL database")
4040
return nil
4141
}

Diff for: cmd/dump.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func runDump(ctx *cli.Context) error {
279279
}()
280280

281281
targetDBType := ctx.String("database")
282-
if len(targetDBType) > 0 && targetDBType != setting.Database.Type {
282+
if len(targetDBType) > 0 && targetDBType != setting.Database.Type.String() {
283283
log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType)
284284
} else {
285285
log.Info("Dumping database...")

Diff for: contrib/init/ubuntu/gitea

+84
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

Diff for: custom/conf/app.example.ini

+16
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
;;

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

+6
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

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

+16-1
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

Diff for: docs/content/doc/advanced/customizing-gitea.en-us.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,22 @@ To add custom .gitignore, add a file with existing [.gitignore rules](https://gi
282282

283283
### Labels
284284

285-
To add a custom label set, add a file that follows the [label format](https://github.com/go-gitea/gitea/blob/main/options/label/Default) to `$GITEA_CUSTOM/options/label`
285+
Starting with Gitea 1.19, you can add a file that follows the [YAML label format](https://github.com/go-gitea/gitea/blob/main/options/label/Advanced.yaml) to `$GITEA_CUSTOM/options/label`:
286+
287+
```yaml
288+
labels:
289+
- name: "foo/bar" # name of the label that will appear in the dropdown
290+
exclusive: true # whether to use the exclusive namespace for scoped labels. scoped delimiter is /
291+
color: aabbcc # hex colour coding
292+
description: Some label # long description of label intent
293+
```
294+
295+
The [legacy file format](https://github.com/go-gitea/gitea/blob/main/options/label/Default) can still be used following the format below, however we strongly recommend using the newer YAML format instead.
296+
286297
`#hex-color label name ; label description`
287298

299+
For more information, see the [labels documentation]({{< relref "doc/usage/labels.en-us.md" >}}).
300+
288301
### Licenses
289302

290303
To add a custom license, add a file with the license text to `$GITEA_CUSTOM/options/license`

0 commit comments

Comments
 (0)