Skip to content

Commit 9a59699

Browse files
committed
Merge branch 'main' of https://github.com/go-gitea/gitea into refactoring-private
2 parents b82ac60 + f088dc4 commit 9a59699

File tree

355 files changed

+5053
-4363
lines changed

Some content is hidden

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

355 files changed

+5053
-4363
lines changed

.drone.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ services:
153153
MYSQL_DATABASE: test
154154

155155
- name: mysql8
156-
image: mysql:8.0
156+
image: mysql:8
157157
environment:
158158
MYSQL_ALLOW_EMPTY_PASSWORD: yes
159159
MYSQL_DATABASE: testgitea
@@ -319,7 +319,7 @@ trigger:
319319
services:
320320
- name: pgsql
321321
pull: default
322-
image: postgres:9.5
322+
image: postgres:10
323323
environment:
324324
POSTGRES_DB: test
325325
POSTGRES_PASSWORD: postgres
@@ -503,7 +503,7 @@ steps:
503503
pull: always
504504
image: techknowlogick/xgo:go-1.16.x
505505
commands:
506-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
506+
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
507507
- export PATH=$PATH:$GOPATH/bin
508508
- make release
509509
environment:
@@ -599,7 +599,7 @@ steps:
599599
pull: always
600600
image: techknowlogick/xgo:go-1.16.x
601601
commands:
602-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
602+
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
603603
- export PATH=$PATH:$GOPATH/bin
604604
- make release
605605
environment:

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Please check the following:
22

3-
1. Make sure you are targeting the `master` branch, pull requests on release branches are only allowed for bug fixes.
3+
1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for bug fixes.
44
2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/master/CONTRIBUTING.md
55
3. Describe what your pull request does and which issue you're targeting (if any)
66

.golangci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ issues:
7070
- path: modules/log/
7171
linters:
7272
- errcheck
73-
- path: routers/routes/web.go
74-
linters:
75-
- dupl
7673
- path: routers/api/v1/repo/issue_subscription.go
7774
linters:
7875
- dupl
@@ -114,3 +111,4 @@ issues:
114111
linters:
115112
- staticcheck
116113
text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
114+

Dockerfile.rootless

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ RUN apk --no-cache add \
3535
ca-certificates \
3636
gettext \
3737
git \
38+
curl \
3839
gnupg
3940

4041
RUN addgroup \
@@ -59,6 +60,8 @@ USER git:git
5960
ENV GITEA_WORK_DIR /var/lib/gitea
6061
ENV GITEA_CUSTOM /var/lib/gitea/custom
6162
ENV GITEA_TEMP /tmp/gitea
63+
ENV TMPDIR /tmp/gitea
64+
6265
#TODO add to docs the ability to define the ini to load (usefull to test and revert a config)
6366
ENV GITEA_APP_INI /etc/gitea/app.ini
6467
ENV HOME "/var/lib/gitea/git"

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ endif
4343
ifeq ($(OS), Windows_NT)
4444
GOFLAGS := -v -buildmode=exe
4545
EXECUTABLE ?= gitea.exe
46+
else ifeq ($(OS), Windows)
47+
GOFLAGS := -v -buildmode=exe
48+
EXECUTABLE ?= gitea.exe
4649
else
4750
GOFLAGS := -v
4851
EXECUTABLE ?= gitea
@@ -61,8 +64,9 @@ EXTRA_GOFLAGS ?=
6164
MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
6265
MAKE_EVIDENCE_DIR := .make_evidence
6366

64-
ifneq ($(RACE_ENABLED),)
65-
GOTESTFLAGS ?= -race
67+
ifeq ($(RACE_ENABLED),true)
68+
GOFLAGS += -race
69+
GOTESTFLAGS += -race
6670
endif
6771

6872
STORED_VERSION_FILE := VERSION
@@ -377,7 +381,7 @@ test-check:
377381
.PHONY: test\#%
378382
test\#%:
379383
@echo "Running go test with -tags '$(TEST_TAGS)'..."
380-
@$(GO) test -mod=vendor -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_PACKAGES)
384+
@$(GO) test -mod=vendor $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_PACKAGES)
381385

382386
.PHONY: coverage
383387
coverage:

cmd/serv.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func fail(userMessage, logMessage string, args ...interface{}) {
8181
}
8282
}
8383

84+
if len(logMessage) > 0 {
85+
_ = private.SSHLog(true, fmt.Sprintf(logMessage+": ", args...))
86+
}
87+
8488
os.Exit(1)
8589
}
8690

cmd/web.go

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ import (
1616
"code.gitea.io/gitea/modules/graceful"
1717
"code.gitea.io/gitea/modules/log"
1818
"code.gitea.io/gitea/modules/setting"
19-
"code.gitea.io/gitea/modules/util"
2019
"code.gitea.io/gitea/routers"
21-
"code.gitea.io/gitea/routers/routes"
20+
"code.gitea.io/gitea/routers/install"
2221

2322
context2 "github.com/gorilla/context"
2423
"github.com/urfave/cli"
@@ -89,7 +88,7 @@ func runWeb(ctx *cli.Context) error {
8988
}
9089

9190
// Perform pre-initialization
92-
needsInstall := routers.PreInstallInit(graceful.GetManager().HammerContext())
91+
needsInstall := install.PreloadSettings(graceful.GetManager().HammerContext())
9392
if needsInstall {
9493
// Flag for port number in case first time run conflict
9594
if ctx.IsSet("port") {
@@ -102,7 +101,7 @@ func runWeb(ctx *cli.Context) error {
102101
return err
103102
}
104103
}
105-
c := routes.InstallRoutes()
104+
c := install.Routes()
106105
err := listen(c, false)
107106
select {
108107
case <-graceful.GetManager().IsShutdown():
@@ -135,7 +134,7 @@ func runWeb(ctx *cli.Context) error {
135134
}
136135

137136
// Set up Chi routes
138-
c := routes.NormalRoutes()
137+
c := routers.NormalRoutes()
139138
err := listen(c, true)
140139
<-graceful.GetManager().Done()
141140
log.Info("PID: %d Gitea Web Finished", os.Getpid())
@@ -152,19 +151,6 @@ func setPort(port string) error {
152151
case setting.FCGI:
153152
case setting.FCGIUnix:
154153
default:
155-
// Save LOCAL_ROOT_URL if port changed
156-
cfg := ini.Empty()
157-
isFile, err := util.IsFile(setting.CustomConf)
158-
if err != nil {
159-
log.Fatal("Unable to check if %s is a file", err)
160-
}
161-
if isFile {
162-
// Keeps custom settings if there is already something.
163-
if err := cfg.Append(setting.CustomConf); err != nil {
164-
return fmt.Errorf("Failed to load custom conf '%s': %v", setting.CustomConf, err)
165-
}
166-
}
167-
168154
defaultLocalURL := string(setting.Protocol) + "://"
169155
if setting.HTTPAddr == "0.0.0.0" {
170156
defaultLocalURL += "localhost"
@@ -173,10 +159,10 @@ func setPort(port string) error {
173159
}
174160
defaultLocalURL += ":" + setting.HTTPPort + "/"
175161

176-
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
177-
if err := cfg.SaveTo(setting.CustomConf); err != nil {
178-
return fmt.Errorf("Error saving generated LOCAL_ROOT_URL to custom config: %v", err)
179-
}
162+
// Save LOCAL_ROOT_URL if port changed
163+
setting.CreateOrAppendToCustomConf(func(cfg *ini.File) {
164+
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
165+
})
180166
}
181167
return nil
182168
}

contrib/pr/checkout.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"code.gitea.io/gitea/modules/setting"
3232
"code.gitea.io/gitea/modules/util"
3333
"code.gitea.io/gitea/routers"
34-
"code.gitea.io/gitea/routers/routes"
3534

3635
"github.com/go-git/go-git/v5"
3736
"github.com/go-git/go-git/v5/config"
@@ -116,7 +115,7 @@ func runPR() {
116115
//routers.GlobalInit()
117116
external.RegisterRenderers()
118117
markup.Init()
119-
c := routes.NormalRoutes()
118+
c := routers.NormalRoutes()
120119

121120
log.Printf("[PR] Ready for testing !\n")
122121
log.Printf("[PR] Login with user1, user2, user3, ... with pass: password\n")

custom/conf/app.example.ini

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ ROUTER = console
444444
;ACCESS_LOG_TEMPLATE = {{.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}}"
445445
;;
446446
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
447+
;;
448+
;; SSH log (Creates log from ssh git request)
449+
;;
450+
;ENABLE_SSH_LOG = false
451+
;;
447452
;; Other Settings
448453
;;
449454
;; Print Stacktraces with logs. (Rarely helpful.) Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "None"
@@ -1140,8 +1145,8 @@ PATH =
11401145
;;
11411146
;; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
11421147
;; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
1143-
;; default is indexers/issues.queue
1144-
;ISSUE_INDEXER_QUEUE_DIR = indexers/issues.queue
1148+
;; default is queues/common
1149+
;ISSUE_INDEXER_QUEUE_DIR = queues/common
11451150
;;
11461151
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
11471152
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
@@ -1196,7 +1201,7 @@ PATH =
11961201
;; default to persistable-channel
11971202
;TYPE = persistable-channel
11981203
;;
1199-
;; data-dir for storing persistable queues and level queues, individual queues will be named by their type
1204+
;; data-dir for storing persistable queues and level queues, individual queues will default to `queues/common` meaning the queue is shared.
12001205
;DATADIR = queues/
12011206
;;
12021207
;; Default queue length before a channel queue will block
@@ -1226,7 +1231,7 @@ PATH =
12261231
;TIMEOUT = 15m30s
12271232
;;
12281233
;; Create a pool with this many workers
1229-
;WORKERS = 1
1234+
;WORKERS = 0
12301235
;;
12311236
;; Dynamically scale the worker pool to at this many workers
12321237
;MAX_WORKERS = 10
@@ -1238,7 +1243,7 @@ PATH =
12381243
;BOOST_TIMEOUT = 5m
12391244
;;
12401245
;; During a boost add BOOST_WORKERS
1241-
;BOOST_WORKERS = 5
1246+
;BOOST_WORKERS = 1
12421247

12431248
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12441249
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docker/root/etc/s6/openssh/setup

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ if [ -d /etc/ssh ]; then
4747
SSH_RSA_CERT="${SSH_RSA_CERT:+"HostCertificate "}${SSH_RSA_CERT}" \
4848
SSH_ECDSA_CERT="${SSH_ECDSA_CERT:+"HostCertificate "}${SSH_ECDSA_CERT}" \
4949
SSH_DSA_CERT="${SSH_DSA_CERT:+"HostCertificate "}${SSH_DSA_CERT}" \
50+
SSH_MAX_STARTUPS="${SSH_MAX_STARTUPS:+"MaxStartups "}${SSH_MAX_STARTUPS}" \
51+
SSH_MAX_SESSIONS="${SSH_MAX_SESSIONS:+"MaxSessions "}${SSH_MAX_SESSIONS}" \
5052
envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config
5153

5254
chmod 0644 /etc/ssh/sshd_config

docker/root/etc/templates/sshd_config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ AddressFamily any
55
ListenAddress 0.0.0.0
66
ListenAddress ::
77

8+
${SSH_MAX_STARTUPS}
9+
${SSH_MAX_SESSIONS}
10+
811
LogLevel INFO
912

1013
HostKey /data/ssh/ssh_host_ed25519_key

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ update: $(THEME)
3131
$(THEME): $(THEME)/theme.toml
3232
$(THEME)/theme.toml:
3333
mkdir -p $$(dirname $@)
34-
curl -s $(ARCHIVE) | tar xz -C $$(dirname $@)
34+
curl -L -s $(ARCHIVE) | tar xz -C $$(dirname $@)

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ relation to port exhaustion.
350350
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch.
351351
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
352352
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`.
353-
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved.
353+
- `ISSUE_INDEXER_QUEUE_DIR`: **queues/common**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved. (Previously this was `indexers/issues.queue`.)
354354
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
355355
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number.
356356

@@ -370,7 +370,7 @@ relation to port exhaustion.
370370
## Queue (`queue` and `queue.*`)
371371

372372
- `TYPE`: **persistable-channel**: General queue type, currently support: `persistable-channel` (uses a LevelDB internally), `channel`, `level`, `redis`, `dummy`
373-
- `DATADIR`: **queues/**: Base DataDir for storing persistent and level queues. `DATADIR` for individual queues can be set in `queue.name` sections but will default to `DATADIR/`**`name`**.
373+
- `DATADIR`: **queues/**: Base DataDir for storing persistent and level queues. `DATADIR` for individual queues can be set in `queue.name` sections but will default to `DATADIR/`**`common`**. (Previously each queue would default to `DATADIR/`**`name`**.)
374374
- `LENGTH`: **20**: Maximal queue size before channel queues block
375375
- `BATCH_LENGTH`: **20**: Batch data before passing to the handler
376376
- `CONN_STR`: **redis://127.0.0.1:6379/0**: Connection string for the redis queue type. Options can be set using query params. Similarly LevelDB options can also be set using: **leveldb://relative/path?option=value** or **leveldb:///absolute/path?option=value**, and will override `DATADIR`
@@ -381,11 +381,11 @@ relation to port exhaustion.
381381
- `MAX_ATTEMPTS`: **10**: Maximum number of attempts to create the wrapped queue
382382
- `TIMEOUT`: **GRACEFUL_HAMMER_TIME + 30s**: Timeout the creation of the wrapped queue if it takes longer than this to create.
383383
- Queues by default come with a dynamically scaling worker pool. The following settings configure this:
384-
- `WORKERS`: **1**: Number of initial workers for the queue.
384+
- `WORKERS`: **0** (v1.14 and before: **1**): Number of initial workers for the queue.
385385
- `MAX_WORKERS`: **10**: Maximum number of worker go-routines for the queue.
386386
- `BLOCK_TIMEOUT`: **1s**: If the queue blocks for this time, boost the number of workers - the `BLOCK_TIMEOUT` will then be doubled before boosting again whilst the boost is ongoing.
387387
- `BOOST_TIMEOUT`: **5m**: Boost workers will timeout after this long.
388-
- `BOOST_WORKERS`: **5**: This many workers will be added to the worker pool if there is a boost.
388+
- `BOOST_WORKERS`: **1** (v1.14 and before: **5**): This many workers will be added to the worker pool if there is a boost.
389389

390390
## Admin (`admin`)
391391

@@ -657,6 +657,7 @@ Default templates for project boards:
657657
- `ROUTER`: **console**: The mode or name of the log the router should log to. (If you set this to `,` it will log to default gitea logger.)
658658
NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take effect. Configure each mode in per mode log subsections `\[log.modename.router\]`.
659659
- `ENABLE_ACCESS_LOG`: **false**: Creates an access.log in NCSA common log format, or as per the following template
660+
- `ENABLE_SSH_LOG`: **false**: save ssh log to log file
660661
- `ACCESS`: **file**: Logging mode for the access logger, use a comma to separate values. Configure each mode in per mode log subsections `\[log.modename.access\]`. By default the file mode will log to `$ROOT_PATH/access.log`. (If you set this to `,` it will log to the default gitea logger.)
661662
- `ACCESS_LOG_TEMPLATE`: **`{{.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}}"`**: Sets the template used to create the access log.
662663
- The following variables are available:

docs/content/doc/developers/hacking-on-gitea.en-us.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ See `make help` for all available `make` targets. Also see [`.drone.yml`](https:
127127

128128
## Building continuously
129129

130-
To run and continously rebuild when source files change:
130+
To run and continuously rebuild when source files change:
131131

132132
```bash
133133
make watch
@@ -216,7 +216,7 @@ You should validate your generated Swagger file and spell-check it with:
216216
make swagger-validate misspell-check
217217
```
218218

219-
You should commit the changed swagger JSON file. The continous integration
219+
You should commit the changed swagger JSON file. The continuous integration
220220
server will check that this has been done using:
221221

222222
```bash
@@ -315,7 +315,7 @@ branches as we will need to update it to main before merging and/or may be
315315
able to help fix issues directly.
316316

317317
Any PR requires two approvals from the Gitea maintainers and needs to pass the
318-
continous integration. Take a look at our
318+
continuous integration. Take a look at our
319319
[`CONTRIBUTING.md`](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md)
320320
document.
321321

docs/content/doc/features/authentication.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ Adds the following fields:
8888
- Bind Password (optional)
8989

9090
- The password for the Bind DN specified above, if any. _Note: The password
91-
is stored in plaintext at the server. As such, ensure that the Bind DN
92-
has as few privileges as possible._
91+
is stored encrypted with the SECRET_KEY on the server. It is still recommended
92+
to ensure that the Bind DN has as few privileges as possible._
9393

9494
- User Search Base **(required)**
9595

docs/content/doc/installation/with-docker-rootless.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ services:
107107
+ - db
108108
+
109109
+ db:
110-
+ image: mysql:5.7
110+
+ image: mysql:8
111111
+ restart: always
112112
+ environment:
113113
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -148,7 +148,7 @@ services:
148148
+ - db
149149
+
150150
+ db:
151-
+ image: postgres:9.6
151+
+ image: postgres:13
152152
+ restart: always
153153
+ environment:
154154
+ - POSTGRES_USER=gitea

docs/content/doc/installation/with-docker.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ services:
137137
+ - db
138138
+
139139
+ db:
140-
+ image: mysql:5.7
140+
+ image: mysql:8
141141
+ restart: always
142142
+ environment:
143143
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -188,7 +188,7 @@ services:
188188
+ - db
189189
+
190190
+ db:
191-
+ image: postgres:9.6
191+
+ image: postgres:13
192192
+ restart: always
193193
+ environment:
194194
+ - POSTGRES_USER=gitea

0 commit comments

Comments
 (0)