Skip to content

Commit 69f2325

Browse files
authored
Merge branch 'main' into fix-acme
2 parents 8665e01 + 4f386e2 commit 69f2325

File tree

18 files changed

+306
-360
lines changed

18 files changed

+306
-360
lines changed

cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func NewMainApp(appVer AppVersion) *cli.App {
165165
app.Commands = append(app.Commands, subCmdWithConfig...)
166166
app.Commands = append(app.Commands, subCmdStandalone...)
167167

168+
setting.InitGiteaEnvVars()
168169
return app
169170
}
170171

cmd/main_test.go

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package cmd
66
import (
77
"fmt"
88
"io"
9-
"os"
109
"path/filepath"
1110
"strings"
1211
"testing"
@@ -113,37 +112,17 @@ func TestCliCmd(t *testing.T) {
113112
_, _ = fmt.Fprint(ctx.App.Writer, makePathOutput(setting.AppWorkPath, setting.CustomPath, setting.CustomConf))
114113
return nil
115114
})
116-
var envBackup []string
117-
for _, s := range os.Environ() {
118-
if strings.HasPrefix(s, "GITEA_") && strings.Contains(s, "=") {
119-
envBackup = append(envBackup, s)
120-
}
121-
}
122-
clearGiteaEnv := func() {
123-
for _, s := range os.Environ() {
124-
if strings.HasPrefix(s, "GITEA_") {
125-
_ = os.Unsetenv(s)
126-
}
127-
}
128-
}
129-
defer func() {
130-
clearGiteaEnv()
131-
for _, s := range envBackup {
132-
k, v, _ := strings.Cut(s, "=")
133-
_ = os.Setenv(k, v)
134-
}
135-
}()
136-
137115
for _, c := range cases {
138-
clearGiteaEnv()
139-
for k, v := range c.env {
140-
_ = os.Setenv(k, v)
141-
}
142-
args := strings.Split(c.cmd, " ") // for test only, "split" is good enough
143-
r, err := runTestApp(app, args...)
144-
assert.NoError(t, err, c.cmd)
145-
assert.NotEmpty(t, c.exp, c.cmd)
146-
assert.Contains(t, r.Stdout, c.exp, c.cmd)
116+
t.Run(c.cmd, func(t *testing.T) {
117+
for k, v := range c.env {
118+
t.Setenv(k, v)
119+
}
120+
args := strings.Split(c.cmd, " ") // for test only, "split" is good enough
121+
r, err := runTestApp(app, args...)
122+
assert.NoError(t, err, c.cmd)
123+
assert.NotEmpty(t, c.exp, c.cmd)
124+
assert.Contains(t, r.Stdout, c.exp, c.cmd)
125+
})
147126
}
148127
}
149128

models/unittest/testdb.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ func InitSettings() {
5959
_ = hash.Register("dummy", hash.NewDummyHasher)
6060

6161
setting.PasswordHashAlgo, _ = hash.SetDefaultPasswordHashAlgorithm("dummy")
62+
setting.InitGiteaEnvVars()
63+
64+
// Avoid loading the git's system config.
65+
// On macOS, system config sets the osxkeychain credential helper, which will cause tests to freeze with a dialog.
66+
// But we do not set it in production at the moment, because it might be a "breaking" change,
67+
// more details are in "modules/git.commonBaseEnvs".
68+
_ = os.Setenv("GIT_CONFIG_NOSYSTEM", "true")
6269
}
6370

6471
// TestOptions represents test options

modules/setting/config_env.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,22 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) {
166166
}
167167
return changed
168168
}
169+
170+
// InitGiteaEnvVars initializes the environment variables for gitea
171+
func InitGiteaEnvVars() {
172+
// Ideally Gitea should only accept the environment variables which it clearly knows instead of unsetting the ones it doesn't want,
173+
// but the ideal behavior would be a breaking change, and it seems not bringing enough benefits to end users,
174+
// so at the moment we could still keep "unsetting the unnecessary environments"
175+
176+
// HOME is managed by Gitea, Gitea's git should use "HOME/.gitconfig".
177+
// But git would try "XDG_CONFIG_HOME/git/config" first if "HOME/.gitconfig" does not exist,
178+
// then our git.InitFull would still write to "XDG_CONFIG_HOME/git/config" if XDG_CONFIG_HOME is set.
179+
_ = os.Unsetenv("XDG_CONFIG_HOME")
180+
181+
_ = os.Unsetenv("GIT_AUTHOR_NAME")
182+
_ = os.Unsetenv("GIT_AUTHOR_EMAIL")
183+
_ = os.Unsetenv("GIT_AUTHOR_DATE")
184+
_ = os.Unsetenv("GIT_COMMITTER_NAME")
185+
_ = os.Unsetenv("GIT_COMMITTER_EMAIL")
186+
_ = os.Unsetenv("GIT_COMMITTER_DATE")
187+
}

options/locale/locale_pt-PT.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ license_desc=Vá buscar <a target="_blank" rel="noopener noreferrer" href="%[1]s
244244

245245
[install]
246246
install=Instalação
247+
installing_desc=Instalando agora, por favor aguarde...
247248
title=Configuração inicial
248249
docker_helper=Se correr o Gitea dentro do Docker, leia a <a target="_blank" rel="noopener noreferrer" href="%s">documentação</a> antes de alterar quaisquer configurações.
249250
require_db_desc=Gitea requer MySQL, PostgreSQL, MSSQL, SQLite3 ou TiDB (protocolo MySQL).
@@ -1015,6 +1016,7 @@ new_repo_helper=Um repositório contém todos os ficheiros do trabalho, incluind
10151016
owner=Proprietário(a)
10161017
owner_helper=Algumas organizações podem não aparecer na lista suspensa devido a um limite máximo de contagem de repositórios.
10171018
repo_name=Nome do repositório
1019+
repo_name_profile_public_hint=.profile é um repositório especial que pode usar para adicionar README.md ao seu perfil público da organização, visível para qualquer pessoa. Certifique-se que é público e inicialize-o com um README na pasta do perfil para começar.
10181020
repo_size=Tamanho do repositório
10191021
template=Modelo
10201022
template_select=Escolha um modelo.
@@ -2860,6 +2862,9 @@ teams.invite.title=Foi-lhe feito um convite para se juntar à equipa <strong>%s<
28602862
teams.invite.by=Convidado(a) por %s
28612863
teams.invite.description=Clique no botão abaixo para se juntar à equipa.
28622864

2865+
view_as_role=Ver como: %s
2866+
view_as_public_hint=Está a ver o README como um utilizador público.
2867+
view_as_member_hint=Está a ver o README como um membro desta organização.
28632868

28642869
[admin]
28652870
maintenance=Manutenção

0 commit comments

Comments
 (0)