Skip to content

Commit 6f15516

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Fix dropdown menu header and mobile view (go-gitea#33108) workflow_dispatch use workflow from trigger branch (go-gitea#33098) [skip ci] Updated translations via Crowdin Trivial fixes (go-gitea#33103) Fix empty git repo handling logic (go-gitea#33101) Refactor legacy line-number and scroll code (go-gitea#33094) Use `Project-URL` metadata field to get a PyPI package's homepage URL (go-gitea#33089) Clean up legacy form CSS styles (go-gitea#33081) [skip ci] Updated translations via Crowdin add myself to maintainers (go-gitea#33088) Make Gitea always use its internal config, ignore `/etc/gitconfig` (go-gitea#33076) Fix "stop time tracking button" on navbar (go-gitea#33084) Fix bleve fuzziness search (go-gitea#33078) Try to fix ACME directory problem (go-gitea#33072) Refactor env var related code (go-gitea#33075)
2 parents 9754baf + 3c1c508 commit 6f15516

Some content is hidden

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

71 files changed

+817
-1126
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Gary Kim <gary@garykim.dev> (@gary-kim)
3131
Guillermo Prandi <gitea.maint@mailfilter.com.ar> (@guillep2k)
3232
Mura Li <typeless@ctli.io> (@typeless)
3333
6543 <6543@obermui.de> (@6543)
34-
jaqra <jaqra@hotmail.com> (@jaqra)
3534
David Svantesson <davidsvantesson@gmail.com> (@davidsvantesson)
3635
a1012112796 <1012112796@qq.com> (@a1012112796)
3736
Karl Heinz Marbaise <kama@soebes.de> (@khmarbaise)
@@ -63,3 +62,4 @@ Yu Liu <1240335630@qq.com> (@HEREYUA)
6362
Kemal Zebari <kemalzebra@gmail.com> (@kemzeb)
6463
Rowan Bohde <rowan.bohde@gmail.com> (@bohde)
6564
hiifong <i@hiif.ong> (@hiifong)
65+
metiftikci <metiftikci@hotmail.com> (@metiftikci)

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

cmd/migrate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
var CmdMigrate = &cli.Command{
1919
Name: "migrate",
2020
Usage: "Migrate the database",
21-
Description: "This is a command for migrating the database, so that you can run gitea admin create-user before starting the server.",
21+
Description: `This is a command for migrating the database, so that you can run "gitea admin create user" before starting the server.`,
2222
Action: runMigrate,
2323
}
2424

cmd/web_acme.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func runACME(listenAddr string, m http.Handler) error {
5454
altTLSALPNPort = p
5555
}
5656

57-
magic := certmagic.NewDefault()
57+
magic := &certmagic.Default
5858
magic.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
5959
// Try to use private CA root if provided, otherwise defaults to system's trust
6060
var certPool *x509.CertPool

custom/conf/app.example.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,10 @@ LEVEL = Info
14851485
;REPO_INDEXER_EXCLUDE =
14861486
;;
14871487
;MAX_FILE_SIZE = 1048576
1488+
;;
1489+
;; Bleve engine has performance problems with fuzzy search, so we limit the fuzziness to 0 by default to disable it.
1490+
;; If you'd like to enable it, you can set it to a value between 0 and 2.
1491+
;TYPE_BLEVE_MAX_FUZZINESS = 0
14881492

14891493
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14901494
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ require (
7171
github.com/google/uuid v1.6.0
7272
github.com/gorilla/feeds v1.2.0
7373
github.com/gorilla/sessions v1.4.0
74-
github.com/h2non/gock v1.2.0
7574
github.com/hashicorp/go-version v1.7.0
7675
github.com/hashicorp/golang-lru/v2 v2.0.7
7776
github.com/huandu/xstrings v1.5.0
@@ -230,7 +229,6 @@ require (
230229
github.com/gorilla/handlers v1.5.2 // indirect
231230
github.com/gorilla/mux v1.8.1 // indirect
232231
github.com/gorilla/securecookie v1.1.2 // indirect
233-
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
234232
github.com/hashicorp/errwrap v1.1.0 // indirect
235233
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
236234
github.com/hashicorp/go-multierror v1.1.1 // indirect

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,6 @@ github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/z
452452
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
453453
github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ=
454454
github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik=
455-
github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE=
456-
github.com/h2non/gock v1.2.0/go.mod h1:tNhoxHYW2W42cYkYb1WqzdbYIieALC99kpYr7rH/BQk=
457-
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
458-
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
459455
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
460456
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
461457
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -599,8 +595,6 @@ github.com/msteinert/pam v1.2.0 h1:mYfjlvN2KYs2Pb9G6nb/1f/nPfAttT/Jee5Sq9r3bGE=
599595
github.com/msteinert/pam v1.2.0/go.mod h1:d2n0DCUK8rGecChV3JzvmsDjOY4R7AYbsNxAT+ftQl0=
600596
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
601597
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
602-
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
603-
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
604598
github.com/niklasfasching/go-org v1.7.0 h1:vyMdcMWWTe/XmANk19F4k8XGBYg0GQ/gJGMimOjGMek=
605599
github.com/niklasfasching/go-org v1.7.0/go.mod h1:WuVm4d45oePiE0eX25GqTDQIt/qPW1T9DGkRscqLW5o=
606600
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=

models/repo/repo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ func (repo *Repository) IsBroken() bool {
279279
}
280280

281281
// MarkAsBrokenEmpty marks the repo as broken and empty
282+
// FIXME: the status "broken" and "is_empty" were abused,
283+
// The code always set them together, no way to distinguish whether a repo is really "empty" or "broken"
282284
func (repo *Repository) MarkAsBrokenEmpty() {
283285
repo.Status = RepositoryBroken
284286
repo.IsEmpty = true

models/unittest/testdb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func InitSettings() {
5959
_ = hash.Register("dummy", hash.NewDummyHasher)
6060

6161
setting.PasswordHashAlgo, _ = hash.SetDefaultPasswordHashAlgorithm("dummy")
62-
setting.InitGiteaEnvVars()
62+
setting.InitGiteaEnvVarsForTesting()
6363
}
6464

6565
// TestOptions represents test options

modules/auth/password/pwn/pwn_test.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,57 @@
44
package pwn
55

66
import (
7+
"errors"
8+
"io"
79
"net/http"
10+
"strings"
811
"testing"
9-
"time"
1012

11-
"github.com/h2non/gock"
1213
"github.com/stretchr/testify/assert"
1314
)
1415

15-
var client = New(WithHTTP(&http.Client{
16-
Timeout: time.Second * 2,
17-
}))
16+
type mockTransport struct{}
17+
18+
func (mockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
19+
if req.URL.Host != "api.pwnedpasswords.com" {
20+
return nil, errors.New("unsupported host")
21+
}
22+
respMap := map[string]string{
23+
"/range/5c1d8": "EAF2F254732680E8AC339B84F3266ECCBB5:1\r\nFC446EB88938834178CB9322C1EE273C2A7:2",
24+
"/range/ba189": "FD4CB34F0378BCB15D23F6FFD28F0775C9E:3\r\nFDF342FCD8C3611DAE4D76E8A992A3E4169:4",
25+
"/range/a1733": "C4CE0F1F0062B27B9E2F41AF0C08218017C:1\r\nFC446EB88938834178CB9322C1EE273C2A7:2\r\nFE81480327C992FE62065A827429DD1318B:0",
26+
"/range/5617b": "FD4CB34F0378BCB15D23F6FFD28F0775C9E:3\r\nFDF342FCD8C3611DAE4D76E8A992A3E4169:4\r\nFE81480327C992FE62065A827429DD1318B:0",
27+
"/range/79082": "FDF342FCD8C3611DAE4D76E8A992A3E4169:4\r\nFE81480327C992FE62065A827429DD1318B:0\r\nAFEF386F56EB0B4BE314E07696E5E6E6536:0",
28+
}
29+
if resp, ok := respMap[req.URL.Path]; ok {
30+
return &http.Response{Request: req, Body: io.NopCloser(strings.NewReader(resp))}, nil
31+
}
32+
return nil, errors.New("unsupported path")
33+
}
1834

1935
func TestPassword(t *testing.T) {
20-
defer gock.Off()
36+
client := New(WithHTTP(&http.Client{Transport: mockTransport{}}))
2137

2238
count, err := client.CheckPassword("", false)
2339
assert.ErrorIs(t, err, ErrEmptyPassword, "blank input should return ErrEmptyPassword")
2440
assert.Equal(t, -1, count)
2541

26-
gock.New("https://api.pwnedpasswords.com").Get("/range/5c1d8").Times(1).Reply(200).BodyString("EAF2F254732680E8AC339B84F3266ECCBB5:1\r\nFC446EB88938834178CB9322C1EE273C2A7:2")
2742
count, err = client.CheckPassword("pwned", false)
2843
assert.NoError(t, err)
2944
assert.Equal(t, 1, count)
3045

31-
gock.New("https://api.pwnedpasswords.com").Get("/range/ba189").Times(1).Reply(200).BodyString("FD4CB34F0378BCB15D23F6FFD28F0775C9E:3\r\nFDF342FCD8C3611DAE4D76E8A992A3E4169:4")
3246
count, err = client.CheckPassword("notpwned", false)
3347
assert.NoError(t, err)
3448
assert.Equal(t, 0, count)
3549

36-
gock.New("https://api.pwnedpasswords.com").Get("/range/a1733").Times(1).Reply(200).BodyString("C4CE0F1F0062B27B9E2F41AF0C08218017C:1\r\nFC446EB88938834178CB9322C1EE273C2A7:2\r\nFE81480327C992FE62065A827429DD1318B:0")
3750
count, err = client.CheckPassword("paddedpwned", true)
3851
assert.NoError(t, err)
3952
assert.Equal(t, 1, count)
4053

41-
gock.New("https://api.pwnedpasswords.com").Get("/range/5617b").Times(1).Reply(200).BodyString("FD4CB34F0378BCB15D23F6FFD28F0775C9E:3\r\nFDF342FCD8C3611DAE4D76E8A992A3E4169:4\r\nFE81480327C992FE62065A827429DD1318B:0")
4254
count, err = client.CheckPassword("paddednotpwned", true)
4355
assert.NoError(t, err)
4456
assert.Equal(t, 0, count)
4557

46-
gock.New("https://api.pwnedpasswords.com").Get("/range/79082").Times(1).Reply(200).BodyString("FDF342FCD8C3611DAE4D76E8A992A3E4169:4\r\nFE81480327C992FE62065A827429DD1318B:0\r\nAFEF386F56EB0B4BE314E07696E5E6E6536:0")
4758
count, err = client.CheckPassword("paddednotpwnedzero", true)
4859
assert.NoError(t, err)
4960
assert.Equal(t, 0, count)

0 commit comments

Comments
 (0)