Skip to content

Commit a27b524

Browse files
authored
Merge branch 'main' into api-file-hist
2 parents 388db13 + 11d519b commit a27b524

File tree

225 files changed

+5191
-4820
lines changed

Some content is hidden

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

225 files changed

+5191
-4820
lines changed

.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/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/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

cmd/mailer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func runSendMail(c *cli.Context) error {
1818
ctx, cancel := installSignals()
1919
defer cancel()
2020

21-
setting.NewContext()
21+
setting.LoadFromExisting()
2222

2323
if err := argsSet(c, "title"); err != nil {
2424
return err

cmd/migrate.go

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

4140
if err := db.InitEngineWithMigration(context.Background(), migrations.Migrate); err != nil {
4241
log.Fatal("Failed to initialize ORM engine: %v", err)

cmd/migrate_storage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ func runMigrateStorage(ctx *cli.Context) error {
121121
log.Info("Custom path: %s", setting.CustomPath)
122122
log.Info("Log path: %s", setting.LogRootPath)
123123
log.Info("Configuration file: %s", setting.CustomConf)
124-
setting.InitDBConfig()
125124

126125
if err := db.InitEngineWithMigration(context.Background(), migrations.Migrate); err != nil {
127126
log.Fatal("Failed to initialize ORM engine: %v", err)

cmd/restore_repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func runRestoreRepository(c *cli.Context) error {
5050
ctx, cancel := installSignals()
5151
defer cancel()
5252

53-
setting.NewContext()
53+
setting.LoadFromExisting()
5454

5555
statusCode, errStr := private.RestoreRepo(
5656
ctx,

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func setup(logPath string, debug bool) {
5858
} else {
5959
_ = log.NewLogger(1000, "console", "console", `{"level":"fatal","stacktracelevel":"NONE","stderr":true}`)
6060
}
61-
setting.NewContext()
61+
setting.LoadFromExisting()
6262
if debug {
6363
setting.RunMode = "dev"
6464
}

cmd/web.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ func runWeb(ctx *cli.Context) error {
124124
}
125125
c := install.Routes()
126126
err := listen(c, false)
127+
if err != nil {
128+
log.Critical("Unable to open listener for installer. Is Gitea already running?")
129+
graceful.GetManager().DoGracefulShutdown()
130+
}
127131
select {
128132
case <-graceful.GetManager().IsShutdown():
129133
<-graceful.GetManager().Done()
@@ -145,7 +149,15 @@ func runWeb(ctx *cli.Context) error {
145149

146150
log.Info("Global init")
147151
// Perform global initialization
148-
routers.GlobalInit(graceful.GetManager().HammerContext())
152+
setting.LoadFromExisting()
153+
routers.GlobalInitInstalled(graceful.GetManager().HammerContext())
154+
155+
// We check that AppDataPath exists here (it should have been created during installation)
156+
// We can't check it in `GlobalInitInstalled`, because some integration tests
157+
// use cmd -> GlobalInitInstalled, but the AppDataPath doesn't exist during those tests.
158+
if _, err := os.Stat(setting.AppDataPath); err != nil {
159+
log.Fatal("Can not find APP_DATA_PATH '%s'", setting.AppDataPath)
160+
}
149161

150162
// Override the provided port number within the configuration
151163
if ctx.IsSet("port") {

contrib/environment-to-ini/environment-to-ini.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func runEnvironmentToIni(c *cli.Context) error {
156156
destination = setting.CustomConf
157157
}
158158
if destination != setting.CustomConf || changed {
159+
log.Info("Settings saved to: %q", destination)
159160
err = cfg.SaveTo(destination)
160161
if err != nil {
161162
return err

contrib/fhs-compliant-script/gitea

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

3-
########################################################################
4-
# This script some defaults for gitea to run in a FHS compliant manner #
5-
########################################################################
3+
#############################################################################
4+
# This script sets some defaults for gitea to run in a FHS compliant manner #
5+
#############################################################################
66

77
# It assumes that you place this script as gitea in /usr/bin
88
#
@@ -36,7 +36,7 @@ if [ -z "$APP_INI_SET" ]; then
3636
CONF_ARG="-c \"$APP_INI\""
3737
fi
3838

39-
# Provide FHS compliant defaults to
40-
exec -a "$0" GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" "$GITEA" $CONF_ARG "$@"
39+
# Provide FHS compliant defaults
40+
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@"
4141

4242

contrib/pr/checkout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func runPR() {
4949
log.Fatal(err)
5050
}
5151
setting.SetCustomPathAndConf("", "", "")
52-
setting.NewContext()
52+
setting.LoadAllowEmpty()
5353

5454
setting.RepoRootPath, err = os.MkdirTemp(os.TempDir(), "repos")
5555
if err != nil {
@@ -215,7 +215,7 @@ func main() {
215215
//Use git cli command for windows
216216
runCmd("git", "fetch", remoteUpstream, fmt.Sprintf("pull/%s/head:%s", pr, branch))
217217
} else {
218-
ref := fmt.Sprintf("refs/pull/%s/head:%s", pr, branchRef)
218+
ref := fmt.Sprintf("%s%s/head:%s", gitea_git.PullPrefix, pr, branchRef)
219219
err = repo.Fetch(&git.FetchOptions{
220220
RemoteName: remoteUpstream,
221221
RefSpecs: []config.RefSpec{

docker/root/etc/s6/gitea/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
[[ -f ./setup ]] && source ./setup
33

44
pushd /app/gitea >/dev/null
5-
exec su-exec $USER /app/gitea/gitea web
5+
exec su-exec $USER /usr/local/bin/gitea web
66
popd

docker/root/usr/local/bin/gitea

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
###############################################################
4+
# This script sets defaults for gitea to run in the container #
5+
###############################################################
6+
7+
# It assumes that you place this script as gitea in /usr/local/bin
8+
#
9+
# And place the original in /usr/lib/gitea with working files in /data/gitea
10+
GITEA="/app/gitea/gitea"
11+
WORK_DIR="/app/gitea"
12+
CUSTOM_PATH="/data/gitea"
13+
14+
# Provide docker defaults
15+
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" GITEA_CUSTOM="${GITEA_CUSTOM:-$CUSTOM_PATH}" exec -a "$0" "$GITEA" $CONF_ARG "$@"
16+
17+

docker/rootless/usr/local/bin/gitea

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
###############################################################
4+
# This script sets defaults for gitea to run in the container #
5+
###############################################################
6+
7+
# It assumes that you place this script as gitea in /usr/local/bin
8+
#
9+
# And place the original in /usr/lib/gitea with working files in /data/gitea
10+
GITEA="/app/gitea/gitea"
11+
WORK_DIR="/var/lib/gitea"
12+
APP_INI="/etc/gitea/app.ini"
13+
14+
APP_INI_SET=""
15+
for i in "$@"; do
16+
case "$i" in
17+
"-c")
18+
APP_INI_SET=1
19+
;;
20+
"-c="*)
21+
APP_INI_SET=1
22+
;;
23+
"--config")
24+
APP_INI_SET=1
25+
;;
26+
"--config="*)
27+
APP_INI_SET=1
28+
;;
29+
*)
30+
;;
31+
esac
32+
done
33+
34+
if [ -z "$APP_INI_SET" ]; then
35+
CONF_ARG="-c \"$APP_INI\""
36+
fi
37+
38+
39+
# Provide docker defaults
40+
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@"
41+
42+

docs/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ params:
1818
description: Git with a cup of tea
1919
author: The Gitea Authors
2020
website: https://docs.gitea.io
21-
version: 1.15.6
21+
version: 1.15.7
2222
minGoVersion: 1.16
2323
goVersion: 1.17
2424
minNodeVersion: 12.17

docs/content/doc/developers/guidelines-backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To maintain understandable code and avoid circular dependencies it is important
3838
- `models/db`: Basic database operations. All other `models/xxx` packages should depend on this package. The `GetEngine` function should only be invoked from `models/`.
3939
- `models/fixtures`: Sample data used in unit tests and integration tests. One `yml` file means one table which will be loaded into database when beginning the tests.
4040
- `models/migrations`: Stores database migrations between versions. PRs that change a database structure **MUST** also have a migration step.
41-
- `modules`: Different modules to handle specific functionality in Gitea. Work in Progress: Some of them should be moved to `services`.
41+
- `modules`: Different modules to handle specific functionality in Gitea. Work in Progress: Some of them should be moved to `services`, in particular those that depend on models because they rely on the database.
4242
- `modules/setting`: Store all system configurations read from ini files and has been referenced by everywhere. But they should be used as function parameters when possible.
4343
- `modules/git`: Package to interactive with `Git` command line or Gogit package.
4444
- `public`: Compiled frontend files (javascript, images, css, etc.)

0 commit comments

Comments
 (0)