Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e63150

Browse files
authored
Merge branch 'main' into load-templates-once-and-better-reload
2 parents cbdc8bc + e24c238 commit 9e63150

31 files changed

+10448
-7596
lines changed

.spectral.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extends: [[spectral:oas, all]]
2+
3+
rules:
4+
info-contact: off
5+
oas2-api-host: off
6+
oas2-parameter-description: off
7+
oas2-schema: off
8+
oas2-valid-schema-example: off
9+
openapi-tags: off
10+
operation-description: off
11+
operation-singular-tag: off
12+
operation-tag-defined: off

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ lint: lint-frontend lint-backend
312312
lint-frontend: node_modules
313313
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js docs/assets/js
314314
npx stylelint --color --max-warnings=0 web_src/less
315+
npx spectral lint -q -F hint $(SWAGGER_SPEC)
315316

316317
.PHONY: lint-backend
317318
lint-backend: golangci-lint vet editorconfig-checker

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ You can display STL file directly in Gitea by adding:
202202

203203
to the file `templates/custom/footer.tmpl`
204204

205-
You also need to download the content of the library [Madeleine.js](https://jinjunho.github.io/Madeleine.js/) and place it under `$GITEA_CUSTOM/public/` folder.
205+
You also need to download the content of the library [Madeleine.js](https://github.com/beige90/Madeleine.js) and place it under `$GITEA_CUSTOM/public/` folder.
206206

207207
You should end-up with a folder structure similar to:
208208

docs/content/doc/advanced/signing.en-us.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ ideal UI and therefore subject to change.
100100
**Since 1.17**, Gitea runs git in its own home directory `[git].HOME_PATH` (default to `%(APP_DATA_PATH)/home`)
101101
and uses its own config `{[git].HOME_PATH}/.gitconfig`.
102102
If you have your own customized git config for Gitea, you should set these configs in system git config (aka `/etc/gitconfig`)
103-
or the Gitea internal git config `{[git].HOME_PATH}/.gitconfig`.
104-
Related home files for git command (like `.gnupg`) should also be put in Gitea's git home directory `[git].HOME_PATH`.
105-
103+
or the Gitea internal git config `{[git].HOME_PATH}/.gitconfig`.
104+
Related home files for git command (like `.gnupg`) should also be put in Gitea's git home directory `[git].HOME_PATH`.
105+
If you like to keep the `.gnupg` directory outside of `{[git].HOME_PATH}/`, consider setting the `$GNUPGHOME` environment variable to your preferred location.
106106

107107
### `INITIAL_COMMIT`
108108

models/perm/access/access.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ func updateUserAccess(accessMap map[int64]*userAccess, user *user_model.User, mo
8686
// FIXME: do cross-comparison so reduce deletions and additions to the minimum?
8787
func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) {
8888
minMode := perm.AccessModeRead
89-
if !repo.IsPrivate {
89+
if err := repo.GetOwner(ctx); err != nil {
90+
return fmt.Errorf("GetOwner: %v", err)
91+
}
92+
93+
// If the repo isn't private and isn't owned by a organization,
94+
// increase the minMode to Write.
95+
if !repo.IsPrivate && !repo.Owner.IsOrganization() {
9096
minMode = perm.AccessModeWrite
9197
}
9298

modules/setting/setting.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -840,16 +840,17 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
840840
SSH.StartBuiltinServer = false
841841
}
842842

843-
trustedUserCaKeys := sec.Key("SSH_TRUSTED_USER_CA_KEYS").Strings(",")
844-
for _, caKey := range trustedUserCaKeys {
843+
SSH.TrustedUserCAKeysFile = sec.Key("SSH_TRUSTED_USER_CA_KEYS_FILENAME").MustString(filepath.Join(SSH.RootPath, "gitea-trusted-user-ca-keys.pem"))
844+
845+
for _, caKey := range SSH.TrustedUserCAKeys {
845846
pubKey, _, _, _, err := gossh.ParseAuthorizedKey([]byte(caKey))
846847
if err != nil {
847848
log.Fatal("Failed to parse TrustedUserCaKeys: %s %v", caKey, err)
848849
}
849850

850851
SSH.TrustedUserCAKeysParsed = append(SSH.TrustedUserCAKeysParsed, pubKey)
851852
}
852-
if len(trustedUserCaKeys) > 0 {
853+
if len(SSH.TrustedUserCAKeys) > 0 {
853854
// Set the default as email,username otherwise we can leave it empty
854855
sec.Key("SSH_AUTHORIZED_PRINCIPALS_ALLOW").MustString("username,email")
855856
} else {
@@ -858,20 +859,6 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
858859

859860
SSH.AuthorizedPrincipalsAllow, SSH.AuthorizedPrincipalsEnabled = parseAuthorizedPrincipalsAllow(sec.Key("SSH_AUTHORIZED_PRINCIPALS_ALLOW").Strings(","))
860861

861-
if !SSH.Disabled && !SSH.StartBuiltinServer {
862-
if err = os.MkdirAll(SSH.KeyTestPath, 0o644); err != nil {
863-
log.Fatal("Failed to create '%s': %v", SSH.KeyTestPath, err)
864-
}
865-
866-
if len(trustedUserCaKeys) > 0 && SSH.AuthorizedPrincipalsEnabled {
867-
fname := sec.Key("SSH_TRUSTED_USER_CA_KEYS_FILENAME").MustString(filepath.Join(SSH.RootPath, "gitea-trusted-user-ca-keys.pem"))
868-
if err := os.WriteFile(fname,
869-
[]byte(strings.Join(trustedUserCaKeys, "\n")), 0o600); err != nil {
870-
log.Fatal("Failed to create '%s': %v", fname, err)
871-
}
872-
}
873-
}
874-
875862
SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool(SSH.MinimumKeySizeCheck)
876863
minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
877864
for _, key := range minimumKeySizes {

modules/ssh/init.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package ssh
6+
7+
import (
8+
"fmt"
9+
"net"
10+
"os"
11+
"path/filepath"
12+
"strconv"
13+
"strings"
14+
15+
"code.gitea.io/gitea/modules/log"
16+
"code.gitea.io/gitea/modules/setting"
17+
)
18+
19+
func Init() error {
20+
if setting.SSH.Disabled {
21+
return nil
22+
}
23+
24+
if setting.SSH.StartBuiltinServer {
25+
Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)
26+
log.Info("SSH server started on %s. Cipher list (%v), key exchange algorithms (%v), MACs (%v)",
27+
net.JoinHostPort(setting.SSH.ListenHost, strconv.Itoa(setting.SSH.ListenPort)),
28+
setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs,
29+
)
30+
return nil
31+
}
32+
33+
builtinUnused()
34+
35+
// FIXME: why 0o644 for a directory .....
36+
if err := os.MkdirAll(setting.SSH.KeyTestPath, 0o644); err != nil {
37+
return fmt.Errorf("failed to create directory %q for ssh key test: %w", setting.SSH.KeyTestPath, err)
38+
}
39+
40+
if len(setting.SSH.TrustedUserCAKeys) > 0 && setting.SSH.AuthorizedPrincipalsEnabled {
41+
caKeysFileName := setting.SSH.TrustedUserCAKeysFile
42+
caKeysFileDir := filepath.Dir(caKeysFileName)
43+
44+
err := os.MkdirAll(caKeysFileDir, 0o700) // SSH.RootPath by default (That is `~/.ssh` in most cases)
45+
if err != nil {
46+
return fmt.Errorf("failed to create directory %q for ssh trusted ca keys: %w", caKeysFileDir, err)
47+
}
48+
49+
if err := os.WriteFile(caKeysFileName, []byte(strings.Join(setting.SSH.TrustedUserCAKeys, "\n")), 0o600); err != nil {
50+
return fmt.Errorf("failed to write ssh trusted ca keys to %q: %w", caKeysFileName, err)
51+
}
52+
}
53+
54+
return nil
55+
}

modules/ssh/ssh_graceful.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func listen(server *ssh.Server) {
2929
log.Info("SSH Listener: %s Closed", server.Addr)
3030
}
3131

32-
// Unused informs our cleanup routine that we will not be using a ssh port
33-
func Unused() {
32+
// builtinUnused informs our cleanup routine that we will not be using a ssh port
33+
func builtinUnused() {
3434
graceful.GetManager().InformCleanup()
3535
}

modules/templates/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ func SVG(icon string, others ...interface{}) template.HTML {
628628

629629
// Avatar renders user avatars. args: user, size (int), class (string)
630630
func Avatar(item interface{}, others ...interface{}) template.HTML {
631-
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
631+
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image vm", others...)
632632

633633
switch t := item.(type) {
634634
case *user_model.User:

options/locale/locale_de-DE.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,6 @@ default_branch=Standardbranch
861861
default_branch_helper=Der default Branch ist der Basisbranch für Pull-Requests und Commits.
862862
mirror_prune=Entfernen
863863
mirror_prune_desc=Entferne veraltete remote-tracking Referenzen
864-
mirror_interval=Mirror-Intervall. Gültige Zeiteinheiten sind 'h', 'm', sowie 's'. 0 deaktiviert die automatische Synchronisierung. (Minimum: %s)
865864
mirror_interval_invalid=Das Spiegel-Intervall ist ungültig.
866865
mirror_address=Klonen via URL
867866
mirror_address_desc=Gib alle erforderlichen Anmeldedaten im Abschnitt "Authentifizierung" ein.

0 commit comments

Comments
 (0)