Skip to content

Commit 2ccc73d

Browse files
committed
Merge branch 'main' into ssh-sign
2 parents 670cc92 + 7d0629a commit 2ccc73d

File tree

219 files changed

+3147
-1769
lines changed

Some content is hidden

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

219 files changed

+3147
-1769
lines changed

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

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: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"time"
1818

1919
"code.gitea.io/gitea/models"
20+
"code.gitea.io/gitea/models/perm"
2021
"code.gitea.io/gitea/modules/git"
2122
"code.gitea.io/gitea/modules/json"
2223
"code.gitea.io/gitea/modules/log"
@@ -57,18 +58,18 @@ func setup(logPath string, debug bool) {
5758
} else {
5859
_ = log.NewLogger(1000, "console", "console", `{"level":"fatal","stacktracelevel":"NONE","stderr":true}`)
5960
}
60-
setting.NewContext()
61+
setting.LoadFromExisting()
6162
if debug {
6263
setting.RunMode = "dev"
6364
}
6465
}
6566

6667
var (
67-
allowedCommands = map[string]models.AccessMode{
68-
"git-upload-pack": models.AccessModeRead,
69-
"git-upload-archive": models.AccessModeRead,
70-
"git-receive-pack": models.AccessModeWrite,
71-
lfsAuthenticateVerb: models.AccessModeNone,
68+
allowedCommands = map[string]perm.AccessMode{
69+
"git-upload-pack": perm.AccessModeRead,
70+
"git-upload-archive": perm.AccessModeRead,
71+
"git-receive-pack": perm.AccessModeWrite,
72+
lfsAuthenticateVerb: perm.AccessModeNone,
7273
}
7374
alphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
7475
)
@@ -214,9 +215,9 @@ func runServ(c *cli.Context) error {
214215

215216
if verb == lfsAuthenticateVerb {
216217
if lfsVerb == "upload" {
217-
requestedMode = models.AccessModeWrite
218+
requestedMode = perm.AccessModeWrite
218219
} else if lfsVerb == "download" {
219-
requestedMode = models.AccessModeRead
220+
requestedMode = perm.AccessModeRead
220221
} else {
221222
return fail("Unknown LFS verb", "Unknown lfs verb %s", lfsVerb)
222223
}

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: 1 addition & 1 deletion
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 {

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ PATH =
900900
;;
901901
;; In default merge messages only include approvers who are official
902902
;DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY = true
903+
;;
904+
;; Add co-authored-by and co-committed-by trailers if committer does not match author
905+
;ADD_CO_COMMITTER_TRAILERS = true
903906

904907
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
905908
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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/content/doc/advanced/adding-legal-pages.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ wget -O /path/to/custom/public/privacy.html https://raw.githubusercontent.com/go
2525

2626
Now you need to edit the page to meet your requirements. In particular you must change the email addresses, web addresses and references to "Your Gitea Instance" to match your situation.
2727

28-
You absolutely must not place a general ToS or privacy statement that implies that the gitea project is responsible for your server.
28+
You absolutely must not place a general ToS or privacy statement that implies that the Gitea project is responsible for your server.
2929

3030
## Make it Visible
3131

docs/content/doc/advanced/cmd-embedded.en-us.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@ To extract resources embedded in Gitea's executable, use the following syntax:
7676
gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...}
7777
```
7878

79-
The `--config` option tells gitea the location of the `app.ini` configuration file if
79+
The `--config` option tells Gitea the location of the `app.ini` configuration file if
8080
it's not in its default location. This option is only used with the `--custom` flag.
8181

82-
The `--destination` option tells gitea the directory where the files must be extracted to.
82+
The `--destination` option tells Gitea the directory where the files must be extracted to.
8383
The default is the current directory.
8484

85-
The `--custom` flag tells gitea to extract the files directly into the `custom` directory.
85+
The `--custom` flag tells Gitea to extract the files directly into the `custom` directory.
8686
For this to work, the command needs to know the location of the `app.ini` configuration
8787
file (`--config`) and, depending of the configuration, be ran from the directory where
8888
gitea normally starts. See [Customizing Gitea]({{< relref "doc/advanced/customizing-gitea.en-us.md" >}}) for details.
8989

9090
The `--overwrite` flag allows any existing files in the destination directory to be overwritten.
9191

92-
The `--rename` flag tells gitea to rename any existing files in the destination directory
92+
The `--rename` flag tells Gitea to rename any existing files in the destination directory
9393
as `filename.bak`. Previous `.bak` files are overwritten.
9494

9595
At least one file search pattern must be provided; see `list` subcomand above for pattern

0 commit comments

Comments
 (0)