Skip to content

Commit 77469ca

Browse files
authored
Merge branch 'main' into ssh_log
2 parents 4e6c2a6 + 1a56599 commit 77469ca

Some content is hidden

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

77 files changed

+1670
-869
lines changed

.drone.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ trigger:
1515
steps:
1616
- name: deps-frontend
1717
pull: always
18-
image: node:14
18+
image: node:16
1919
commands:
2020
- make node_modules
2121

2222
- name: lint-frontend
23-
image: node:14
23+
image: node:16
2424
commands:
2525
- make lint-frontend
2626
depends_on: [deps-frontend]
@@ -58,7 +58,7 @@ steps:
5858
TAGS: bindata gogit sqlite sqlite_unlock_notify
5959

6060
- name: checks-frontend
61-
image: node:14
61+
image: node:16
6262
commands:
6363
- make checks-frontend
6464
depends_on: [deps-frontend]
@@ -71,13 +71,13 @@ steps:
7171
depends_on: [lint-backend]
7272

7373
- name: test-frontend
74-
image: node:14
74+
image: node:16
7575
commands:
7676
- make test-frontend
7777
depends_on: [lint-frontend]
7878

7979
- name: build-frontend
80-
image: node:14
80+
image: node:16
8181
commands:
8282
- make frontend
8383
depends_on: [test-frontend]
@@ -530,7 +530,7 @@ steps:
530530
image: plugins/s3:1
531531
settings:
532532
acl: public-read
533-
bucket: releases
533+
bucket: gitea-artifacts
534534
endpoint: https://storage.gitea.io
535535
path_style: true
536536
source: "dist/release/*"
@@ -551,7 +551,7 @@ steps:
551551
image: plugins/s3:1
552552
settings:
553553
acl: public-read
554-
bucket: releases
554+
bucket: gitea-artifacts
555555
endpoint: https://storage.gitea.io
556556
path_style: true
557557
source: "dist/release/*"
@@ -626,7 +626,7 @@ steps:
626626
image: plugins/s3:1
627627
settings:
628628
acl: public-read
629-
bucket: releases
629+
bucket: gitea-artifacts
630630
endpoint: https://storage.gitea.io
631631
path_style: true
632632
source: "dist/release/*"

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ rules:
366366
unicorn/no-array-instanceof: [0]
367367
unicorn/no-array-push-push: [2]
368368
unicorn/no-console-spaces: [0]
369+
unicorn/no-document-cookie: [2]
369370
unicorn/no-fn-reference-in-iterator: [0]
370371
unicorn/no-for-loop: [0]
371372
unicorn/no-hex-escape: [0]
@@ -389,6 +390,7 @@ rules:
389390
unicorn/numeric-separators-style: [0]
390391
unicorn/prefer-add-event-listener: [2]
391392
unicorn/prefer-array-find: [2]
393+
unicorn/prefer-array-flat-map: [2]
392394
unicorn/prefer-array-flat: [2]
393395
unicorn/prefer-array-index-of: [2]
394396
unicorn/prefer-array-some: [2]
@@ -399,8 +401,10 @@ rules:
399401
unicorn/prefer-includes: [2]
400402
unicorn/prefer-math-trunc: [2]
401403
unicorn/prefer-modern-dom-apis: [0]
404+
unicorn/prefer-module: [2]
402405
unicorn/prefer-negative-index: [2]
403406
unicorn/prefer-node-append: [0]
407+
unicorn/prefer-node-protocol: [0]
404408
unicorn/prefer-node-remove: [0]
405409
unicorn/prefer-number-properties: [0]
406410
unicorn/prefer-optional-catch-binding: [2]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ cpu.out
7676
/integrations/mssql.ini
7777
/node_modules
7878
/yarn.lock
79+
/yarn-error.log
80+
/npm-debug.log*
7981
/public/js
8082
/public/serviceworker.js
8183
/public/css

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ test-backend:
359359
@$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='$(TEST_TAGS)' $(GO_PACKAGES)
360360

361361
.PHONY: test-frontend
362-
test-frontend:
362+
test-frontend: node_modules
363363
@NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --color
364364

365365
.PHONY: test-check

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ NOTES:
101101
1. **YOU MUST READ THE [CONTRIBUTORS GUIDE](CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST.**
102102
2. If you have found a vulnerability in the project, please write privately to **[email protected]**. Thanks!
103103

104+
## Translating
105+
106+
Translations are done through Crowdin. If you want to translate to a new language ask one of the managers in the Crowdin project to add a new language there.
107+
108+
You can also just create an issue for adding a language or ask on discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord. For general translation questions there is a section in the docs. Currently a bit empty but we hope fo fill it as questions pop up.
109+
110+
https://docs.gitea.io/en-us/translation-guidelines/
111+
112+
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
113+
104114
## Further information
105115

106116
For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.io/en-us/).

README_ZH.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ Gitea 的首要目标是创建一个极易安装,运行非常快速,安装
7171

7272
Fork -> Patch -> Push -> Pull Request
7373

74+
## 翻译
75+
76+
多语言翻译是基于Crowdin进行的.
77+
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
78+
7479
## 作者
7580

7681
* [Maintainers](https://github.com/orgs/go-gitea/people)

cmd/web_letsencrypt.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package cmd
66

77
import (
88
"net/http"
9+
"strconv"
910
"strings"
1011

1112
"code.gitea.io/gitea/modules/log"
@@ -22,6 +23,11 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
2223
// TODO: these are placeholders until we add options for each in settings with appropriate warning
2324
enableHTTPChallenge := true
2425
enableTLSALPNChallenge := true
26+
altHTTPPort := 0
27+
28+
if p, err := strconv.Atoi(setting.PortToRedirect); err == nil {
29+
altHTTPPort = p
30+
}
2531

2632
magic := certmagic.NewDefault()
2733
magic.Storage = &certmagic.FileStorage{Path: directory}
@@ -30,6 +36,8 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
3036
Agreed: setting.LetsEncryptTOS,
3137
DisableHTTPChallenge: !enableHTTPChallenge,
3238
DisableTLSALPNChallenge: !enableTLSALPNChallenge,
39+
ListenHost: listenAddr,
40+
AltHTTPPort: altHTTPPort,
3341
})
3442

3543
magic.Issuers = []certmagic.Issuer{myACME}

contrib/environment-to-ini/environment-to-ini.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ func runEnvironmentToIni(c *cli.Context) error {
110110
}
111111
cfg.NameMapper = ini.SnackCase
112112

113+
changed := false
114+
113115
prefix := c.String("prefix") + "__"
114116

115117
for _, kv := range os.Environ() {
@@ -143,15 +145,21 @@ func runEnvironmentToIni(c *cli.Context) error {
143145
continue
144146
}
145147
}
148+
oldValue := key.Value()
149+
if !changed && oldValue != value {
150+
changed = true
151+
}
146152
key.SetValue(value)
147153
}
148154
destination := c.String("out")
149155
if len(destination) == 0 {
150156
destination = setting.CustomConf
151157
}
152-
err = cfg.SaveTo(destination)
153-
if err != nil {
154-
return err
158+
if destination != setting.CustomConf || changed {
159+
err = cfg.SaveTo(destination)
160+
if err != nil {
161+
return err
162+
}
155163
}
156164
if c.Bool("clear") {
157165
for _, kv := range os.Environ() {

docker/root/etc/s6/openssh/setup

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,29 @@ if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then
2424
ssh-keygen -t ecdsa -b 256 -f /data/ssh/ssh_host_ecdsa_key -N "" > /dev/null
2525
fi
2626

27+
if [ -e /data/ssh/ssh_host_ed25519_cert ]; then
28+
SSH_ED25519_CERT=${SSH_ED25519_CERT:-"/data/ssh/ssh_host_ed25519_cert"}
29+
fi
30+
31+
if [ -e /data/ssh/ssh_host_rsa_cert ]; then
32+
SSH_RSA_CERT=${SSH_RSA_CERT:-"/data/ssh/ssh_host_rsa_cert"}
33+
fi
34+
35+
if [ -e /data/ssh/ssh_host_ecdsa_cert ]; then
36+
SSH_ECDSA_CERT=${SSH_ECDSA_CERT:-"/data/ssh/ssh_host_ecdsa_cert"}
37+
fi
38+
39+
if [ -e /data/ssh/ssh_host_dsa_cert ]; then
40+
SSH_DSA_CERT=${SSH_DSA_CERT:-"/data/ssh/ssh_host_dsa_cert"}
41+
fi
42+
2743
if [ -d /etc/ssh ]; then
2844
SSH_PORT=${SSH_PORT:-"22"} \
2945
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
46+
SSH_ED25519_CERT="${SSH_ED25519_CERT:+"HostCertificate "}${SSH_ED25519_CERT}" \
47+
SSH_RSA_CERT="${SSH_RSA_CERT:+"HostCertificate "}${SSH_RSA_CERT}" \
48+
SSH_ECDSA_CERT="${SSH_ECDSA_CERT:+"HostCertificate "}${SSH_ECDSA_CERT}" \
49+
SSH_DSA_CERT="${SSH_DSA_CERT:+"HostCertificate "}${SSH_DSA_CERT}" \
3050
envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config
3151

3252
chmod 0644 /etc/ssh/sshd_config

docker/root/etc/templates/sshd_config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ ListenAddress ::
88
LogLevel INFO
99

1010
HostKey /data/ssh/ssh_host_ed25519_key
11-
HostCertificate /data/ssh/ssh_host_ed25519_cert
11+
${SSH_ED25519_CERT}
1212
HostKey /data/ssh/ssh_host_rsa_key
13-
HostCertificate /data/ssh/ssh_host_rsa_cert
13+
${SSH_RSA_CERT}
1414
HostKey /data/ssh/ssh_host_ecdsa_key
15-
HostCertificate /data/ssh/ssh_host_ecdsa_cert
15+
${SSH_ECDSA_CERT}
1616
HostKey /data/ssh/ssh_host_dsa_key
17-
HostCertificate /data/ssh/ssh_host_dsa_cert
17+
${SSH_DSA_CERT}
1818

1919
AuthorizedKeysFile .ssh/authorized_keys
2020
AuthorizedPrincipalsFile .ssh/authorized_principals

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ Gitea includes built-in log rotation, which should be enough for most deployment
437437

438438
- Disable built-in log rotation by setting `LOG_ROTATE` to `false` in your `app.ini`.
439439
- Install `logrotate`.
440-
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10`, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
441-
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
440+
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10` to the `gitea` process itself, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
441+
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
442+
- If you are using docker and are running from outside of the container you can use `docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'` or `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'` or send `USR1` directly to the gitea process itself.
442443

443444
The next `logrotate` jobs will include your configurations, so no restart is needed. You can also immediately reload `logrotate` with `logrotate /etc/logrotate.conf --force`.

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,24 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
222222
<?xml version="1.0" encoding="UTF-8"?>
223223
<configuration>
224224
<system.webServer>
225+
<security>
226+
<requestFiltering>
227+
<hiddenSegments>
228+
<clear />
229+
</hiddenSegments>
230+
<denyUrlSequences>
231+
<clear />
232+
</denyUrlSequences>
233+
<fileExtensions allowUnlisted="true">
234+
<clear />
235+
</fileExtensions>
236+
</requestFiltering>
237+
</security>
225238
<rewrite>
226-
<rules>
239+
<rules useOriginalURLEncoding="false">
227240
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
228241
<match url="(.*)" />
229-
<action type="Rewrite" url="http://127.0.0.1:3000/{R:1}" />
242+
<action type="Rewrite" url="http://127.0.0.1:3000{UNENCODED_URL}" />
230243
<serverVariables>
231244
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="HTTP_ACCEPT_ENCODING" />
232245
<set name="HTTP_ACCEPT_ENCODING" value="" />
@@ -255,6 +268,16 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
255268
</outboundRules>
256269
</rewrite>
257270
<urlCompression doDynamicCompression="true" />
271+
<handlers>
272+
<clear />
273+
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
274+
</handlers>
275+
<!-- Map all extensions to the same MIME type, so all files can be
276+
downloaded. -->
277+
<staticContent>
278+
<clear />
279+
<mimeMap fileExtension="*" mimeType="application/octet-stream" />
280+
</staticContent>
258281
</system.webServer>
259282
</configuration>
260283
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ require (
105105
github.com/unknwon/com v1.0.1
106106
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44
107107
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae
108-
github.com/unrolled/render v1.1.0
108+
github.com/unrolled/render v1.1.1
109109
github.com/urfave/cli v1.22.5
110110
github.com/willf/bitset v1.1.11 // indirect
111111
github.com/xanzy/go-gitlab v0.48.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44 h1:7bSo/vjZKVYUoZfxpY
10991099
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
11001100
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs=
11011101
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM=
1102-
github.com/unrolled/render v1.1.0 h1:gvpR9hHxTt6DcGqRYuVVFcfd8rtK+nyEPUJN06KB57Q=
1103-
github.com/unrolled/render v1.1.0/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM=
1102+
github.com/unrolled/render v1.1.1 h1:FpzNzkvlJQIlVdVaqeVBGWiCS8gpbmjtrKpDmCn6p64=
1103+
github.com/unrolled/render v1.1.1/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM=
11041104
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
11051105
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
11061106
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export default {
22
setupFilesAfterEnv: ['jest-extended'],
33
testTimeout: 20000,
4+
rootDir: 'web_src',
45
testMatch: [
5-
'**/web_src/**/*.test.js',
6+
'<rootDir>/**/*.test.js',
67
],
78
transform: {},
89
verbose: false,

models/avatar_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ func TestHashEmail(t *testing.T) {
4040
}
4141

4242
func TestSizedAvatarLink(t *testing.T) {
43+
setting.AppSubURL = "/testsuburl"
44+
4345
disableGravatar()
44-
assert.Equal(t, "/suburl/assets/img/avatar_default.png",
46+
assert.Equal(t, "/testsuburl/assets/img/avatar_default.png",
4547
SizedAvatarLink("[email protected]", 100))
4648

4749
enableGravatar(t)

models/gpg_key_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ MkM/fdpyc2hY7Dl/+qFmN5MG5yGmMpQcX+RNNR222ibNC1D3wg==
103103
=i9b7
104104
-----END PGP PUBLIC KEY BLOCK-----`
105105
keys, err := checkArmoredGPGKeyString(testGPGArmor)
106+
if !assert.NotEmpty(t, keys) {
107+
return
108+
}
106109
ekey := keys[0]
107110
assert.NoError(t, err, "Could not parse a valid GPG armored key", ekey)
108111

@@ -189,6 +192,10 @@ Unknown GPG key with good email
189192
}
190193

191194
func TestCheckGPGUserEmail(t *testing.T) {
195+
assert.NoError(t, PrepareTestDatabase())
196+
197+
_ = AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
198+
192199
testEmailWithUpperCaseLetters := `-----BEGIN PGP PUBLIC KEY BLOCK-----
193200
Version: GnuPG v1
194201
@@ -222,9 +229,11 @@ Q0KHb+QcycSgbDx0ZAvdIacuKvBBcbxrsmFUI4LR+oIup0G9gUc0roPvr014jYQL
222229

223230
keys, err := AddGPGKey(1, testEmailWithUpperCaseLetters)
224231
assert.NoError(t, err)
225-
key := keys[0]
226-
if assert.Len(t, key.Emails, 1) {
227-
assert.Equal(t, "[email protected]", key.Emails[0].Email)
232+
if assert.NotEmpty(t, keys) {
233+
key := keys[0]
234+
if assert.Len(t, key.Emails, 1) {
235+
assert.Equal(t, "[email protected]", key.Emails[0].Email)
236+
}
228237
}
229238
}
230239

@@ -374,7 +383,9 @@ epiDVQ==
374383
`
375384
keys, err := checkArmoredGPGKeyString(testIssue6599)
376385
assert.NoError(t, err)
377-
ekey := keys[0]
378-
expire := getExpiryTime(ekey)
379-
assert.Equal(t, time.Unix(1586105389, 0), expire)
386+
if assert.NotEmpty(t, keys) {
387+
ekey := keys[0]
388+
expire := getExpiryTime(ekey)
389+
assert.Equal(t, time.Unix(1586105389, 0), expire)
390+
}
380391
}

0 commit comments

Comments
 (0)