Skip to content

Commit e628e20

Browse files
authored
Merge branch 'main' into main
2 parents a75b139 + e79272a commit e628e20

File tree

836 files changed

+19097
-16563
lines changed

Some content is hidden

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

836 files changed

+19097
-16563
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ steps:
537537

538538
- name: static
539539
pull: always
540-
image: techknowlogick/xgo:go-1.16.x
540+
image: techknowlogick/xgo:go-1.17.x
541541
commands:
542542
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
543543
- export PATH=$PATH:$GOPATH/bin
@@ -633,7 +633,7 @@ steps:
633633

634634
- name: static
635635
pull: always
636-
image: techknowlogick/xgo:go-1.16.x
636+
image: techknowlogick/xgo:go-1.17.x
637637
commands:
638638
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
639639
- export PATH=$PATH:$GOPATH/bin

.eslintrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ignorePatterns:
66

77
parserOptions:
88
sourceType: module
9-
ecmaVersion: 2021
9+
ecmaVersion: latest
1010

1111
plugins:
1212
- eslint-plugin-unicorn
@@ -109,7 +109,7 @@ rules:
109109
github/no-implicit-buggy-globals: [0]
110110
github/no-inner-html: [0]
111111
github/no-innerText: [2]
112-
github/no-then: [2]
112+
github/no-then: [0]
113113
github/no-useless-passive: [2]
114114
github/prefer-observers: [0]
115115
github/require-passive-events: [2]
@@ -384,6 +384,7 @@ rules:
384384
unicorn/no-array-instanceof: [0]
385385
unicorn/no-array-method-this-argument: [2]
386386
unicorn/no-array-push-push: [2]
387+
unicorn/no-await-expression-member: [0]
387388
unicorn/no-console-spaces: [0]
388389
unicorn/no-document-cookie: [2]
389390
unicorn/no-empty-file: [2]
@@ -419,6 +420,7 @@ rules:
419420
unicorn/prefer-array-index-of: [2]
420421
unicorn/prefer-array-some: [2]
421422
unicorn/prefer-at: [0]
423+
unicorn/prefer-code-point: [2]
422424
unicorn/prefer-dataset: [2]
423425
unicorn/prefer-date-now: [2]
424426
unicorn/prefer-default-parameters: [0]

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7+
## [1.15.7](https://github.com/go-gitea/gitea/releases/tag/v1.15.7) - 2021-12-01
8+
9+
* ENHANCEMENTS
10+
* Only allow webhook to send requests to allowed hosts (#17482) (#17510)
11+
* Fix login redirection links (#17451) (#17473)
12+
* BUGFIXES
13+
* Fix database inconsistent when admin change user email (#17549) (#17840)
14+
* Use correct user on releases (#17806) (#17818)
15+
* Fix commit count in tag view (#17698) (#17790)
16+
* Fix close issue but time watcher still running (#17643) (#17761)
17+
* Fix Migrate Description (#17692) (#17727)
18+
* Fix bug when project board get open issue number (#17703) (#17726)
19+
* Return 400 but not 500 when request archive with wrong format (#17691) (#17700)
20+
* Fix bug when read mysql database max lifetime (#17682) (#17690)
21+
* Fix database deadlock when update issue labels (#17649) (#17665)
22+
* Fix bug on detect issue/comment writer (#17592)
23+
* Remove appSubUrl from pasted images (#17572) (#17588)
24+
* Make `ParsePatch` more robust (#17573) (#17580)
25+
* Fix stats upon searching issues (#17566) (#17578)
26+
* Escape issue titles in comments list (#17555) (#17556)
27+
* Fix zero created time bug on commit api (#17546) (#17547)
28+
* Fix database keyword quote problem on migration v161 (#17522) (#17523)
29+
* Fix email with + when active (#17518) (#17520)
30+
* Stop double encoding blame commit messages (#17498) (#17500)
31+
* Quote the table name in CountOrphanedObjects (#17487) (#17488)
32+
* Run Migrate in Install rather than just SyncTables (#17475) (#17486)
33+
* BUILD
34+
* Fix golangci-lint warnings (#17598 et al) (#17668)
35+
* MISC
36+
* Preserve color when inverting emojis (#17797) (#17799)
37+
738
## [1.15.6](https://github.com/go-gitea/gitea/releases/tag/v1.15.6) - 2021-10-28
839

940
* BUGFIXES

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,5 @@ CMD ["/bin/s6-svscan", "/etc/s6"]
6666
COPY docker/root /
6767
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
6868
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
69-
RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/environment-to-ini
69+
RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
7070
RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/*
71-
RUN ln -s /app/gitea/gitea /usr/local/bin/gitea

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ RUN mkdir -p /var/lib/gitea /etc/gitea
5353
RUN chown git:git /var/lib/gitea /etc/gitea
5454

5555
COPY docker/rootless /
56-
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /usr/local/bin/gitea
56+
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
5757
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
58-
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /usr/local/bin/gitea /usr/local/bin/environment-to-ini
58+
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
5959

6060
#git:git
6161
USER 1000:1000

build/code-batch-process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ func main() {
267267
logVerbose("batch cmd: %s %v", subCmd, substArgs)
268268
switch subCmd {
269269
case "gitea-fmt":
270-
cmdErrors = append(cmdErrors, passThroughCmd("gofmt", substArgs))
271270
if containsString(subArgs, "-w") {
272271
cmdErrors = append(cmdErrors, giteaFormatGoImports(files))
273272
}
273+
cmdErrors = append(cmdErrors, passThroughCmd("gofmt", substArgs))
274274
case "misspell":
275275
cmdErrors = append(cmdErrors, passThroughCmd("misspell", substArgs))
276276
default:

build/generate-images.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ async function main() {
8080
]);
8181
}
8282

83-
main().then(exit).catch(exit); // eslint-disable-line github/no-then
83+
main().then(exit).catch(exit);
8484

build/generate-svg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ async function main() {
5454
]);
5555
}
5656

57-
main().then(exit).catch(exit); // eslint-disable-line github/no-then
57+
main().then(exit).catch(exit);
5858

cmd/admin.go

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import (
1414
"text/tabwriter"
1515

1616
"code.gitea.io/gitea/models"
17+
asymkey_model "code.gitea.io/gitea/models/asymkey"
1718
"code.gitea.io/gitea/models/db"
1819
"code.gitea.io/gitea/models/login"
20+
user_model "code.gitea.io/gitea/models/user"
1921
"code.gitea.io/gitea/modules/git"
2022
"code.gitea.io/gitea/modules/graceful"
2123
"code.gitea.io/gitea/modules/log"
@@ -297,6 +299,36 @@ var (
297299
Name: "skip-local-2fa",
298300
Usage: "Set to true to skip local 2fa for users authenticated by this source",
299301
},
302+
cli.StringSliceFlag{
303+
Name: "scopes",
304+
Value: nil,
305+
Usage: "Scopes to request when to authenticate against this OAuth2 source",
306+
},
307+
cli.StringFlag{
308+
Name: "required-claim-name",
309+
Value: "",
310+
Usage: "Claim name that has to be set to allow users to login with this source",
311+
},
312+
cli.StringFlag{
313+
Name: "required-claim-value",
314+
Value: "",
315+
Usage: "Claim value that has to be set to allow users to login with this source",
316+
},
317+
cli.StringFlag{
318+
Name: "group-claim-name",
319+
Value: "",
320+
Usage: "Claim name providing group names for this source",
321+
},
322+
cli.StringFlag{
323+
Name: "admin-group",
324+
Value: "",
325+
Usage: "Group Claim value for administrator users",
326+
},
327+
cli.StringFlag{
328+
Name: "restricted-group",
329+
Value: "",
330+
Usage: "Group Claim value for restricted users",
331+
},
300332
}
301333

302334
microcmdAuthUpdateOauth = cli.Command{
@@ -358,15 +390,15 @@ func runChangePassword(c *cli.Context) error {
358390
return errors.New("The password you chose is on a list of stolen passwords previously exposed in public data breaches. Please try again with a different password.\nFor more details, see https://haveibeenpwned.com/Passwords")
359391
}
360392
uname := c.String("username")
361-
user, err := models.GetUserByName(uname)
393+
user, err := user_model.GetUserByName(uname)
362394
if err != nil {
363395
return err
364396
}
365397
if err = user.SetPassword(c.String("password")); err != nil {
366398
return err
367399
}
368400

369-
if err = models.UpdateUserCols(user, "passwd", "passwd_hash_algo", "salt"); err != nil {
401+
if err = user_model.UpdateUserCols(db.DefaultContext, user, "passwd", "passwd_hash_algo", "salt"); err != nil {
370402
return err
371403
}
372404

@@ -424,15 +456,15 @@ func runCreateUser(c *cli.Context) error {
424456

425457
// If this is the first user being created.
426458
// Take it as the admin and don't force a password update.
427-
if n := models.CountUsers(); n == 0 {
459+
if n := user_model.CountUsers(); n == 0 {
428460
changePassword = false
429461
}
430462

431463
if c.IsSet("must-change-password") {
432464
changePassword = c.Bool("must-change-password")
433465
}
434466

435-
u := &models.User{
467+
u := &user_model.User{
436468
Name: username,
437469
Email: c.String("email"),
438470
Passwd: password,
@@ -442,7 +474,7 @@ func runCreateUser(c *cli.Context) error {
442474
Theme: setting.UI.DefaultTheme,
443475
}
444476

445-
if err := models.CreateUser(u); err != nil {
477+
if err := user_model.CreateUser(u); err != nil {
446478
return fmt.Errorf("CreateUser: %v", err)
447479
}
448480

@@ -471,7 +503,7 @@ func runListUsers(c *cli.Context) error {
471503
return err
472504
}
473505

474-
users, err := models.GetAllUsers()
506+
users, err := user_model.GetAllUsers()
475507

476508
if err != nil {
477509
return err
@@ -516,13 +548,13 @@ func runDeleteUser(c *cli.Context) error {
516548
}
517549

518550
var err error
519-
var user *models.User
551+
var user *user_model.User
520552
if c.IsSet("email") {
521-
user, err = models.GetUserByEmail(c.String("email"))
553+
user, err = user_model.GetUserByEmail(c.String("email"))
522554
} else if c.IsSet("username") {
523-
user, err = models.GetUserByName(c.String("username"))
555+
user, err = user_model.GetUserByName(c.String("username"))
524556
} else {
525-
user, err = models.GetUserByID(c.Int64("id"))
557+
user, err = user_model.GetUserByID(c.Int64("id"))
526558
}
527559
if err != nil {
528560
return err
@@ -624,7 +656,7 @@ func runRegenerateKeys(_ *cli.Context) error {
624656
if err := initDB(ctx); err != nil {
625657
return err
626658
}
627-
return models.RewriteAllPublicKeys()
659+
return asymkey_model.RewriteAllPublicKeys()
628660
}
629661

630662
func parseOAuth2Config(c *cli.Context) *oauth2.Source {
@@ -647,6 +679,12 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
647679
CustomURLMapping: customURLMapping,
648680
IconURL: c.String("icon-url"),
649681
SkipLocalTwoFA: c.Bool("skip-local-2fa"),
682+
Scopes: c.StringSlice("scopes"),
683+
RequiredClaimName: c.String("required-claim-name"),
684+
RequiredClaimValue: c.String("required-claim-value"),
685+
GroupClaimName: c.String("group-claim-name"),
686+
AdminGroup: c.String("admin-group"),
687+
RestrictedGroup: c.String("restricted-group"),
650688
}
651689
}
652690

@@ -709,6 +747,28 @@ func runUpdateOauth(c *cli.Context) error {
709747
oAuth2Config.IconURL = c.String("icon-url")
710748
}
711749

750+
if c.IsSet("scopes") {
751+
oAuth2Config.Scopes = c.StringSlice("scopes")
752+
}
753+
754+
if c.IsSet("required-claim-name") {
755+
oAuth2Config.RequiredClaimName = c.String("required-claim-name")
756+
757+
}
758+
if c.IsSet("required-claim-value") {
759+
oAuth2Config.RequiredClaimValue = c.String("required-claim-value")
760+
}
761+
762+
if c.IsSet("group-claim-name") {
763+
oAuth2Config.GroupClaimName = c.String("group-claim-name")
764+
}
765+
if c.IsSet("admin-group") {
766+
oAuth2Config.AdminGroup = c.String("admin-group")
767+
}
768+
if c.IsSet("restricted-group") {
769+
oAuth2Config.RestrictedGroup = c.String("restricted-group")
770+
}
771+
712772
// update custom URL mapping
713773
var customURLMapping = &oauth2.CustomURLMapping{}
714774

cmd/cmd.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"syscall"
1717

1818
"code.gitea.io/gitea/models/db"
19+
"code.gitea.io/gitea/modules/log"
1920
"code.gitea.io/gitea/modules/setting"
2021
"code.gitea.io/gitea/modules/util"
2122

@@ -57,15 +58,17 @@ func confirm() (bool, error) {
5758
}
5859

5960
func initDB(ctx context.Context) error {
60-
return initDBDisableConsole(ctx, false)
61-
}
62-
63-
func initDBDisableConsole(ctx context.Context, disableConsole bool) error {
64-
setting.NewContext()
61+
setting.LoadFromExisting()
6562
setting.InitDBConfig()
66-
setting.NewXORMLogService(disableConsole)
63+
setting.NewXORMLogService(false)
64+
65+
if setting.Database.Type == "" {
66+
log.Fatal(`Database settings are missing from the configuration file: %q.
67+
Ensure you are running in the correct environment or set the correct configuration file with -c.
68+
If this is the intended configuration file complete the [database] section.`, setting.CustomConf)
69+
}
6770
if err := db.InitEngine(ctx); err != nil {
68-
return fmt.Errorf("models.SetEngine: %v", err)
71+
return fmt.Errorf("unable to initialise the database using the configuration in %q. Error: %v", setting.CustomConf, err)
6972
}
7073
return nil
7174
}

cmd/convert.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func runConvert(ctx *cli.Context) error {
3535
log.Info("Custom path: %s", setting.CustomPath)
3636
log.Info("Log path: %s", setting.LogRootPath)
3737
log.Info("Configuration file: %s", setting.CustomConf)
38-
setting.InitDBConfig()
3938

4039
if !setting.Database.UseMySQL {
4140
fmt.Println("This command can only be used with a MySQL database")

cmd/doctor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func runRecreateTable(ctx *cli.Context) error {
8787
golog.SetPrefix("")
8888
golog.SetOutput(log.NewLoggerAsWriter("INFO", log.GetLogger(log.DEFAULT)))
8989

90-
setting.NewContext()
90+
setting.LoadFromExisting()
9191
setting.InitDBConfig()
9292

9393
setting.EnableXORMLog = ctx.Bool("debug")

cmd/dump.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ func runDump(ctx *cli.Context) error {
159159
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
160160
}
161161
}
162-
setting.NewContext()
162+
setting.LoadFromExisting()
163+
163164
// make sure we are logging to the console no matter what the configuration tells us do to
164165
if _, err := setting.Cfg.Section("log").NewKey("MODE", "console"); err != nil {
165166
fatal("Setting logging mode to console failed: %v", err)

cmd/dump_repo.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ func runDumpRepository(ctx *cli.Context) error {
8888
log.Info("Custom path: %s", setting.CustomPath)
8989
log.Info("Log path: %s", setting.LogRootPath)
9090
log.Info("Configuration file: %s", setting.CustomConf)
91-
setting.InitDBConfig()
9291

9392
var (
9493
serviceType structs.GitServiceType

cmd/embedded.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func initEmbeddedExtractor(c *cli.Context) error {
115115
log.DelNamedLogger(log.DEFAULT)
116116

117117
// Read configuration file
118-
setting.NewContext()
118+
setting.LoadAllowEmpty()
119119

120120
pats, err := getPatterns(c.Args())
121121
if err != nil {

cmd/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func runHookPostReceive(c *cli.Context) error {
309309
defer cancel()
310310

311311
// First of all run update-server-info no matter what
312-
if _, err := git.NewCommand("update-server-info").SetParentContext(ctx).Run(); err != nil {
312+
if _, err := git.NewCommandContext(ctx, "update-server-info").Run(); err != nil {
313313
return fmt.Errorf("Failed to call 'git update-server-info': %v", err)
314314
}
315315

0 commit comments

Comments
 (0)