Skip to content

Commit cd6391b

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-3796-add-reindex-button-to-settings
2 parents 4def566 + bbffcc3 commit cd6391b

File tree

670 files changed

+9542
-10243
lines changed

Some content is hidden

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

670 files changed

+9542
-10243
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ rules:
368368
unicorn/no-array-push-push: [2]
369369
unicorn/no-console-spaces: [0]
370370
unicorn/no-document-cookie: [2]
371+
unicorn/no-empty-file: [2]
371372
unicorn/no-fn-reference-in-iterator: [0]
372373
unicorn/no-for-loop: [0]
373374
unicorn/no-hex-escape: [0]
@@ -404,6 +405,7 @@ rules:
404405
unicorn/prefer-date-now: [2]
405406
unicorn/prefer-default-parameters: [0]
406407
unicorn/prefer-event-key: [2]
408+
unicorn/prefer-export-from: [2]
407409
unicorn/prefer-includes: [2]
408410
unicorn/prefer-math-trunc: [2]
409411
unicorn/prefer-modern-dom-apis: [0]

.github/pull_request_template.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
<!--
2+
13
Please check the following:
24
35
1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for bug fixes.
46
2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/master/CONTRIBUTING.md
57
3. Describe what your pull request does and which issue you're targeting (if any)
68
7-
**You MUST delete the content above including this line before posting, otherwise your pull request will be invalid.**
9+
-->

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ linters:
99
- unused
1010
- structcheck
1111
- varcheck
12-
- golint
1312
- dupl
1413
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
1514
- gofmt

.revive.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ warningCode = 1
2323
[rule.unexported-return]
2424
[rule.indent-error-flow]
2525
[rule.errorf]
26+
[rule.duplicated-imports]

.stylelintrc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
extends: stylelint-config-standard
22

3+
overrides:
4+
- files: ["**/*.less"]
5+
customSyntax: postcss-less
6+
37
rules:
8+
alpha-value-notation: null
49
at-rule-empty-line-before: null
510
block-closing-brace-empty-line-before: null
11+
color-function-notation: null
612
color-hex-length: null
713
comment-empty-line-before: null
14+
declaration-block-no-redundant-longhand-properties: null
815
declaration-block-single-line-max-declarations: null
916
declaration-empty-line-before: null
17+
hue-degree-notation: null
1018
indentation: 2
19+
max-line-length: null
1120
no-descending-specificity: null
21+
no-invalid-position-at-import-rule: null
1222
number-leading-zero: never
23+
number-max-precision: null
24+
property-no-vendor-prefix: null
1325
rule-empty-line-before: null
26+
selector-class-pattern: null
27+
selector-id-pattern: null
1428
selector-pseudo-element-colon-notation: double
1529
shorthand-property-no-redundant-values: true
16-
no-invalid-position-at-import-rule: null
30+
string-quotes: null
31+
value-no-vendor-prefix: null

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Alexey Makhov <[email protected]> (@makhov)
2-
Andrey Nering <[email protected]> (@andreynering)
32
Bo-Yi Wu <[email protected]> (@appleboy)
43
Ethan Koenig <[email protected]> (@ethantkoenig)
54
Kees de Vries <[email protected]> (@Bwko)
@@ -45,3 +44,4 @@ Janis Estelmann <[email protected]> (@KN4CK3R)
4544
Steven Kriegler <[email protected]> (@justusbunsi)
4645
Jimmy Praet <[email protected]> (@jpraet)
4746
Leon Hofmeister <[email protected]> (@delvh)
47+
Gusted <[email protected]) (@Gusted)

cmd/admin.go

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ func runChangePassword(c *cli.Context) error {
339339
return err
340340
}
341341

342-
if err := initDB(); err != nil {
342+
ctx, cancel := installSignals()
343+
defer cancel()
344+
345+
if err := initDB(ctx); err != nil {
343346
return err
344347
}
345348
if !pwd.IsComplexEnough(c.String("password")) {
@@ -393,7 +396,10 @@ func runCreateUser(c *cli.Context) error {
393396
fmt.Fprintf(os.Stderr, "--name flag is deprecated. Use --username instead.\n")
394397
}
395398

396-
if err := initDB(); err != nil {
399+
ctx, cancel := installSignals()
400+
defer cancel()
401+
402+
if err := initDB(ctx); err != nil {
397403
return err
398404
}
399405

@@ -456,7 +462,10 @@ func runCreateUser(c *cli.Context) error {
456462
}
457463

458464
func runListUsers(c *cli.Context) error {
459-
if err := initDB(); err != nil {
465+
ctx, cancel := installSignals()
466+
defer cancel()
467+
468+
if err := initDB(ctx); err != nil {
460469
return err
461470
}
462471

@@ -493,7 +502,10 @@ func runDeleteUser(c *cli.Context) error {
493502
return fmt.Errorf("You must provide the id, username or email of a user to delete")
494503
}
495504

496-
if err := initDB(); err != nil {
505+
ctx, cancel := installSignals()
506+
defer cancel()
507+
508+
if err := initDB(ctx); err != nil {
497509
return err
498510
}
499511

@@ -525,7 +537,10 @@ func runDeleteUser(c *cli.Context) error {
525537
}
526538

527539
func runRepoSyncReleases(_ *cli.Context) error {
528-
if err := initDB(); err != nil {
540+
ctx, cancel := installSignals()
541+
defer cancel()
542+
543+
if err := initDB(ctx); err != nil {
529544
return err
530545
}
531546

@@ -591,14 +606,20 @@ func getReleaseCount(id int64) (int64, error) {
591606
}
592607

593608
func runRegenerateHooks(_ *cli.Context) error {
594-
if err := initDB(); err != nil {
609+
ctx, cancel := installSignals()
610+
defer cancel()
611+
612+
if err := initDB(ctx); err != nil {
595613
return err
596614
}
597615
return repo_module.SyncRepositoryHooks(graceful.GetManager().ShutdownContext())
598616
}
599617

600618
func runRegenerateKeys(_ *cli.Context) error {
601-
if err := initDB(); err != nil {
619+
ctx, cancel := installSignals()
620+
defer cancel()
621+
622+
if err := initDB(ctx); err != nil {
602623
return err
603624
}
604625
return models.RewriteAllPublicKeys()
@@ -628,7 +649,10 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
628649
}
629650

630651
func runAddOauth(c *cli.Context) error {
631-
if err := initDB(); err != nil {
652+
ctx, cancel := installSignals()
653+
defer cancel()
654+
655+
if err := initDB(ctx); err != nil {
632656
return err
633657
}
634658

@@ -645,7 +669,10 @@ func runUpdateOauth(c *cli.Context) error {
645669
return fmt.Errorf("--id flag is missing")
646670
}
647671

648-
if err := initDB(); err != nil {
672+
ctx, cancel := installSignals()
673+
defer cancel()
674+
675+
if err := initDB(ctx); err != nil {
649676
return err
650677
}
651678

@@ -712,7 +739,10 @@ func runUpdateOauth(c *cli.Context) error {
712739
}
713740

714741
func runListAuth(c *cli.Context) error {
715-
if err := initDB(); err != nil {
742+
ctx, cancel := installSignals()
743+
defer cancel()
744+
745+
if err := initDB(ctx); err != nil {
716746
return err
717747
}
718748

@@ -748,7 +778,10 @@ func runDeleteAuth(c *cli.Context) error {
748778
return fmt.Errorf("--id flag is missing")
749779
}
750780

751-
if err := initDB(); err != nil {
781+
ctx, cancel := installSignals()
782+
defer cancel()
783+
784+
if err := initDB(ctx); err != nil {
752785
return err
753786
}
754787

cmd/admin_auth_ldap.go

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

77
import (
8+
"context"
89
"fmt"
910
"strings"
1011

@@ -16,7 +17,7 @@ import (
1617

1718
type (
1819
authService struct {
19-
initDB func() error
20+
initDB func(ctx context.Context) error
2021
createLoginSource func(loginSource *login.Source) error
2122
updateLoginSource func(loginSource *login.Source) error
2223
getLoginSourceByID func(id int64) (*login.Source, error)
@@ -299,7 +300,10 @@ func (a *authService) addLdapBindDn(c *cli.Context) error {
299300
return err
300301
}
301302

302-
if err := a.initDB(); err != nil {
303+
ctx, cancel := installSignals()
304+
defer cancel()
305+
306+
if err := a.initDB(ctx); err != nil {
303307
return err
304308
}
305309

@@ -321,7 +325,10 @@ func (a *authService) addLdapBindDn(c *cli.Context) error {
321325

322326
// updateLdapBindDn updates a new LDAP via Bind DN authentication source.
323327
func (a *authService) updateLdapBindDn(c *cli.Context) error {
324-
if err := a.initDB(); err != nil {
328+
ctx, cancel := installSignals()
329+
defer cancel()
330+
331+
if err := a.initDB(ctx); err != nil {
325332
return err
326333
}
327334

@@ -344,7 +351,10 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
344351
return err
345352
}
346353

347-
if err := a.initDB(); err != nil {
354+
ctx, cancel := installSignals()
355+
defer cancel()
356+
357+
if err := a.initDB(ctx); err != nil {
348358
return err
349359
}
350360

@@ -366,7 +376,10 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
366376

367377
// updateLdapBindDn updates a new LDAP (simple auth) authentication source.
368378
func (a *authService) updateLdapSimpleAuth(c *cli.Context) error {
369-
if err := a.initDB(); err != nil {
379+
ctx, cancel := installSignals()
380+
defer cancel()
381+
382+
if err := a.initDB(ctx); err != nil {
370383
return err
371384
}
372385

cmd/admin_auth_ldap_test.go

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

77
import (
8+
"context"
89
"testing"
910

1011
"code.gitea.io/gitea/models/login"
@@ -207,7 +208,7 @@ func TestAddLdapBindDn(t *testing.T) {
207208
// Mock functions.
208209
var createdLoginSource *login.Source
209210
service := &authService{
210-
initDB: func() error {
211+
initDB: func(context.Context) error {
211212
return nil
212213
},
213214
createLoginSource: func(loginSource *login.Source) error {
@@ -438,7 +439,7 @@ func TestAddLdapSimpleAuth(t *testing.T) {
438439
// Mock functions.
439440
var createdLoginSource *login.Source
440441
service := &authService{
441-
initDB: func() error {
442+
initDB: func(context.Context) error {
442443
return nil
443444
},
444445
createLoginSource: func(loginSource *login.Source) error {
@@ -863,7 +864,7 @@ func TestUpdateLdapBindDn(t *testing.T) {
863864
// Mock functions.
864865
var updatedLoginSource *login.Source
865866
service := &authService{
866-
initDB: func() error {
867+
initDB: func(context.Context) error {
867868
return nil
868869
},
869870
createLoginSource: func(loginSource *login.Source) error {
@@ -1227,7 +1228,7 @@ func TestUpdateLdapSimpleAuth(t *testing.T) {
12271228
// Mock functions.
12281229
var updatedLoginSource *login.Source
12291230
service := &authService{
1230-
initDB: func() error {
1231+
initDB: func(context.Context) error {
12311232
return nil
12321233
},
12331234
createLoginSource: func(loginSource *login.Source) error {

cmd/cmd.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,15 @@ func confirm() (bool, error) {
5656
}
5757
}
5858

59-
func initDB() error {
60-
return initDBDisableConsole(false)
59+
func initDB(ctx context.Context) error {
60+
return initDBDisableConsole(ctx, false)
6161
}
6262

63-
func initDBDisableConsole(disableConsole bool) error {
63+
func initDBDisableConsole(ctx context.Context, disableConsole bool) error {
6464
setting.NewContext()
6565
setting.InitDBConfig()
66-
6766
setting.NewXORMLogService(disableConsole)
68-
if err := db.InitEngine(); err != nil {
67+
if err := db.InitEngine(ctx); err != nil {
6968
return fmt.Errorf("models.SetEngine: %v", err)
7069
}
7170
return nil

cmd/convert.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ var CmdConvert = cli.Command{
2323
}
2424

2525
func runConvert(ctx *cli.Context) error {
26-
if err := initDB(); err != nil {
26+
stdCtx, cancel := installSignals()
27+
defer cancel()
28+
29+
if err := initDB(stdCtx); err != nil {
2730
return err
2831
}
2932

cmd/docs.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ func runDocs(ctx *cli.Context) error {
4343
// Clean up markdown. The following bug was fixed in v2, but is present in v1.
4444
// It affects markdown output (even though the issue is referring to man pages)
4545
// https://github.com/urfave/cli/issues/1040
46-
docs = docs[strings.Index(docs, "#"):]
46+
firstHashtagIndex := strings.Index(docs, "#")
47+
48+
if firstHashtagIndex > 0 {
49+
docs = docs[firstHashtagIndex:]
50+
}
4751
}
4852

4953
out := os.Stdout

cmd/doctor.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ func runRecreateTable(ctx *cli.Context) error {
9696
setting.Cfg.Section("log").Key("XORM").SetValue(",")
9797

9898
setting.NewXORMLogService(!ctx.Bool("debug"))
99-
if err := db.InitEngine(); err != nil {
99+
stdCtx, cancel := installSignals()
100+
defer cancel()
101+
102+
if err := db.InitEngine(stdCtx); err != nil {
100103
fmt.Println(err)
101104
fmt.Println("Check if you are using the right config file. You can use a --config directive to specify one.")
102105
return nil
@@ -128,6 +131,9 @@ func runDoctor(ctx *cli.Context) error {
128131
log.DelNamedLogger("console")
129132
log.DelNamedLogger(log.DEFAULT)
130133

134+
stdCtx, cancel := installSignals()
135+
defer cancel()
136+
131137
// Now setup our own
132138
logFile := ctx.String("log-file")
133139
if !ctx.IsSet("log-file") {
@@ -210,5 +216,5 @@ func runDoctor(ctx *cli.Context) error {
210216

211217
logger := log.GetLogger("doctorouter")
212218
defer logger.Close()
213-
return doctor.RunChecks(logger, ctx.Bool("fix"), checks)
219+
return doctor.RunChecks(stdCtx, logger, ctx.Bool("fix"), checks)
214220
}

0 commit comments

Comments
 (0)