Skip to content

Commit 7866341

Browse files
authored
Merge branch 'main' into fix-15894-run-settings-for-install-page
2 parents 12f3b56 + 21cde5c commit 7866341

File tree

196 files changed

+2378
-1778
lines changed

Some content is hidden

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

196 files changed

+2378
-1778
lines changed

Dockerfile.rootless

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ USER git:git
6060
ENV GITEA_WORK_DIR /var/lib/gitea
6161
ENV GITEA_CUSTOM /var/lib/gitea/custom
6262
ENV GITEA_TEMP /tmp/gitea
63+
ENV TMPDIR /tmp/gitea
64+
6365
#TODO add to docs the ability to define the ini to load (usefull to test and revert a config)
6466
ENV GITEA_APP_INI /etc/gitea/app.ini
6567
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/web.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ 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"
2120
"code.gitea.io/gitea/routers/routes"
2221

@@ -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
}

custom/conf/app.example.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,8 @@ PATH =
11451145
;;
11461146
;; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
11471147
;; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
1148-
;; default is indexers/issues.queue
1149-
;ISSUE_INDEXER_QUEUE_DIR = indexers/issues.queue
1148+
;; default is queues/common
1149+
;ISSUE_INDEXER_QUEUE_DIR = queues/common
11501150
;;
11511151
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
11521152
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
@@ -1201,7 +1201,7 @@ PATH =
12011201
;; default to persistable-channel
12021202
;TYPE = persistable-channel
12031203
;;
1204-
;; 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.
12051205
;DATADIR = queues/
12061206
;;
12071207
;; Default queue length before a channel queue will block
@@ -1231,7 +1231,7 @@ PATH =
12311231
;TIMEOUT = 15m30s
12321232
;;
12331233
;; Create a pool with this many workers
1234-
;WORKERS = 1
1234+
;WORKERS = 0
12351235
;;
12361236
;; Dynamically scale the worker pool to at this many workers
12371237
;MAX_WORKERS = 10
@@ -1243,7 +1243,7 @@ PATH =
12431243
;BOOST_TIMEOUT = 5m
12441244
;;
12451245
;; During a boost add BOOST_WORKERS
1246-
;BOOST_WORKERS = 5
1246+
;BOOST_WORKERS = 1
12471247

12481248
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12491249
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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: 4 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

integrations/api_admin_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func TestAPIEditUser(t *testing.T) {
195195
assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string))
196196

197197
user2 := models.AssertExistsAndLoadBean(t, &models.User{LoginName: "user2"}).(*models.User)
198-
assert.Equal(t, false, user2.IsRestricted)
198+
assert.False(t, user2.IsRestricted)
199199
bTrue := true
200200
req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
201201
// required
@@ -206,5 +206,5 @@ func TestAPIEditUser(t *testing.T) {
206206
})
207207
session.MakeRequest(t, req, http.StatusOK)
208208
user2 = models.AssertExistsAndLoadBean(t, &models.User{LoginName: "user2"}).(*models.User)
209-
assert.Equal(t, true, user2.IsRestricted)
209+
assert.True(t, user2.IsRestricted)
210210
}

integrations/api_gpg_keys_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,42 +78,42 @@ func TestGPGKeys(t *testing.T) {
7878

7979
primaryKey1 := keys[0] //Primary key 1
8080
assert.EqualValues(t, "38EA3BCED732982C", primaryKey1.KeyID)
81-
assert.EqualValues(t, 1, len(primaryKey1.Emails))
81+
assert.Len(t, primaryKey1.Emails, 1)
8282
assert.EqualValues(t, "[email protected]", primaryKey1.Emails[0].Email)
83-
assert.EqualValues(t, true, primaryKey1.Emails[0].Verified)
83+
assert.True(t, primaryKey1.Emails[0].Verified)
8484

8585
subKey := primaryKey1.SubsKey[0] //Subkey of 38EA3BCED732982C
8686
assert.EqualValues(t, "70D7C694D17D03AD", subKey.KeyID)
87-
assert.EqualValues(t, 0, len(subKey.Emails))
87+
assert.Empty(t, subKey.Emails)
8888

8989
primaryKey2 := keys[1] //Primary key 2
9090
assert.EqualValues(t, "FABF39739FE1E927", primaryKey2.KeyID)
91-
assert.EqualValues(t, 1, len(primaryKey2.Emails))
91+
assert.Len(t, primaryKey2.Emails, 1)
9292
assert.EqualValues(t, "[email protected]", primaryKey2.Emails[0].Email)
93-
assert.EqualValues(t, false, primaryKey2.Emails[0].Verified)
93+
assert.False(t, primaryKey2.Emails[0].Verified)
9494

9595
var key api.GPGKey
9696
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey1.ID, 10)+"?token="+token) //Primary key 1
9797
resp = session.MakeRequest(t, req, http.StatusOK)
9898
DecodeJSON(t, resp, &key)
9999
assert.EqualValues(t, "38EA3BCED732982C", key.KeyID)
100-
assert.EqualValues(t, 1, len(key.Emails))
100+
assert.Len(t, key.Emails, 1)
101101
assert.EqualValues(t, "[email protected]", key.Emails[0].Email)
102-
assert.EqualValues(t, true, key.Emails[0].Verified)
102+
assert.True(t, key.Emails[0].Verified)
103103

104104
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(subKey.ID, 10)+"?token="+token) //Subkey of 38EA3BCED732982C
105105
resp = session.MakeRequest(t, req, http.StatusOK)
106106
DecodeJSON(t, resp, &key)
107107
assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID)
108-
assert.EqualValues(t, 0, len(key.Emails))
108+
assert.Empty(t, key.Emails)
109109

110110
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey2.ID, 10)+"?token="+token) //Primary key 2
111111
resp = session.MakeRequest(t, req, http.StatusOK)
112112
DecodeJSON(t, resp, &key)
113113
assert.EqualValues(t, "FABF39739FE1E927", key.KeyID)
114-
assert.EqualValues(t, 1, len(key.Emails))
114+
assert.Len(t, key.Emails, 1)
115115
assert.EqualValues(t, "[email protected]", key.Emails[0].Email)
116-
assert.EqualValues(t, false, key.Emails[0].Verified)
116+
assert.False(t, key.Emails[0].Verified)
117117

118118
})
119119

@@ -124,23 +124,23 @@ func TestGPGKeys(t *testing.T) {
124124
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/not-signed?token="+token)
125125
resp := session.MakeRequest(t, req, http.StatusOK)
126126
DecodeJSON(t, resp, &branch)
127-
assert.EqualValues(t, false, branch.Commit.Verification.Verified)
127+
assert.False(t, branch.Commit.Verification.Verified)
128128
})
129129

130130
t.Run("SignedWithNotValidatedEmail", func(t *testing.T) {
131131
var branch api.Branch
132132
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign-not-yet-validated?token="+token)
133133
resp := session.MakeRequest(t, req, http.StatusOK)
134134
DecodeJSON(t, resp, &branch)
135-
assert.EqualValues(t, false, branch.Commit.Verification.Verified)
135+
assert.False(t, branch.Commit.Verification.Verified)
136136
})
137137

138138
t.Run("SignedWithValidEmail", func(t *testing.T) {
139139
var branch api.Branch
140140
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign?token="+token)
141141
resp := session.MakeRequest(t, req, http.StatusOK)
142142
DecodeJSON(t, resp, &branch)
143-
assert.EqualValues(t, true, branch.Commit.Verification.Verified)
143+
assert.True(t, branch.Commit.Verification.Verified)
144144
})
145145
})
146146
}

integrations/api_issue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func TestAPICreateIssue(t *testing.T) {
6565
resp := session.MakeRequest(t, req, http.StatusCreated)
6666
var apiIssue api.Issue
6767
DecodeJSON(t, resp, &apiIssue)
68-
assert.Equal(t, apiIssue.Body, body)
69-
assert.Equal(t, apiIssue.Title, title)
68+
assert.Equal(t, body, apiIssue.Body)
69+
assert.Equal(t, title, apiIssue.Title)
7070

7171
models.AssertExistsAndLoadBean(t, &models.Issue{
7272
RepoID: repoBefore.ID,

integrations/api_notification_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ func TestAPINotification(t *testing.T) {
4545

4646
assert.Len(t, apiNL, 3)
4747
assert.EqualValues(t, 4, apiNL[0].ID)
48-
assert.EqualValues(t, true, apiNL[0].Unread)
49-
assert.EqualValues(t, false, apiNL[0].Pinned)
48+
assert.True(t, apiNL[0].Unread)
49+
assert.False(t, apiNL[0].Pinned)
5050
assert.EqualValues(t, 3, apiNL[1].ID)
51-
assert.EqualValues(t, false, apiNL[1].Unread)
52-
assert.EqualValues(t, true, apiNL[1].Pinned)
51+
assert.False(t, apiNL[1].Unread)
52+
assert.True(t, apiNL[1].Pinned)
5353
assert.EqualValues(t, 2, apiNL[2].ID)
54-
assert.EqualValues(t, false, apiNL[2].Unread)
55-
assert.EqualValues(t, false, apiNL[2].Pinned)
54+
assert.False(t, apiNL[2].Unread)
55+
assert.False(t, apiNL[2].Pinned)
5656

5757
// -- GET /repos/{owner}/{repo}/notifications --
5858
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?status-types=unread&token=%s", user2.Name, repo1.Name, token))
@@ -74,8 +74,8 @@ func TestAPINotification(t *testing.T) {
7474
DecodeJSON(t, resp, &apiN)
7575

7676
assert.EqualValues(t, 5, apiN.ID)
77-
assert.EqualValues(t, false, apiN.Pinned)
78-
assert.EqualValues(t, true, apiN.Unread)
77+
assert.False(t, apiN.Pinned)
78+
assert.True(t, apiN.Unread)
7979
assert.EqualValues(t, "issue4", apiN.Subject.Title)
8080
assert.EqualValues(t, "Issue", apiN.Subject.Type)
8181
assert.EqualValues(t, thread5.Issue.APIURL(), apiN.Subject.URL)

integrations/api_oauth2_apps_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func testAPIGetOAuth2Application(t *testing.T) {
123123
assert.EqualValues(t, existApp.ClientID, expectedApp.ClientID)
124124
assert.Len(t, expectedApp.ClientID, 36)
125125
assert.Empty(t, expectedApp.ClientSecret)
126-
assert.EqualValues(t, len(expectedApp.RedirectURIs), 1)
126+
assert.Len(t, expectedApp.RedirectURIs, 1)
127127
assert.EqualValues(t, existApp.RedirectURIs[0], expectedApp.RedirectURIs[0])
128128
models.AssertExistsAndLoadBean(t, &models.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})
129129
}
@@ -156,7 +156,7 @@ func testAPIUpdateOAuth2Application(t *testing.T) {
156156
DecodeJSON(t, resp, &app)
157157
expectedApp := app
158158

159-
assert.EqualValues(t, len(expectedApp.RedirectURIs), 2)
159+
assert.Len(t, expectedApp.RedirectURIs, 2)
160160
assert.EqualValues(t, expectedApp.RedirectURIs[0], appBody.RedirectURIs[0])
161161
assert.EqualValues(t, expectedApp.RedirectURIs[1], appBody.RedirectURIs[1])
162162
models.AssertExistsAndLoadBean(t, &models.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})

integrations/api_org_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestAPIOrgCreate(t *testing.T) {
6969
// user1 on this org is public
7070
var users []*api.User
7171
DecodeJSON(t, resp, &users)
72-
assert.EqualValues(t, 1, len(users))
72+
assert.Len(t, users, 1)
7373
assert.EqualValues(t, "user1", users[0].UserName)
7474
})
7575
}

0 commit comments

Comments
 (0)