From 4aee8719f57b40f8645905c10ba8966b29052295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Dachary?= Date: Fri, 24 Feb 2023 13:38:29 +0100 Subject: [PATCH] [BRANDING] alias {FORGEJO,GITEA}_{CUSTOM,WORK_DIR} FORGEJO_* environment variables are set to the corresponding GITEA_* variable when the cli starts. This approach is intended to minimize the conflicts on rebase. All occurences of GITEA_* are left untouched in the codebase and they are only changed to FORGEJO_* if exposed to the user. (cherry picked from commit e466f9d10e145a3ed750f0c86cfcafad5f141ea8) (cherry picked from commit e33e95931b0d91c41433db68ddb19a8724b8ed80) (cherry picked from commit 2cfc6519b7cbc758f8322fd7f7b84dfc6d14ae73) (cherry picked from commit af8864373a65441c817dad1c3b696157c4024a7e) (cherry picked from commit a0550ff3391f0575b72c3d0d1fdf1fcd9b51e4d6) (cherry picked from commit 24dc0a5191a26fac0aef6b3a53fd58b9185edc88) (cherry picked from commit e255eea2b48ad39eeb3eae227ca0d4fd4b667d99) (cherry picked from commit 0c4f5afa7a37e6b805efb452b9d4166f7e2cec61) (cherry picked from commit 42fce708d05d616ebbdfb2eecf384ad2fdaa1d7a) (cherry picked from commit e7278c3c22b656e5730ec2ba0c1b4ee2ef6627ce) (cherry picked from commit 0fb9ed7e0eb5db59ab5b574d3d69b4b161f50b0b) (cherry picked from commit a98308aa4d6659f46f7f69996167f9c2f3c4e859) (cherry picked from commit b8695fcbe04792cb75acb62fdf9c6dee237e8365) --- main.go | 18 +++++++++++++++--- modules/setting/setting.go | 3 +++ routers/web/admin/config.go | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 49093eb8a7..8fac94eb44 100644 --- a/main.go +++ b/main.go @@ -50,11 +50,20 @@ func init() { originalSubcommandHelpTemplate = cli.SubcommandHelpTemplate } +func forgejoEnv() { + for _, k := range []string{"CUSTOM", "WORK_DIR"} { + if v, ok := os.LookupEnv("FORGEJO_" + k); ok { + os.Setenv("GITEA_"+k, v) + } + } +} + func main() { + forgejoEnv() app := cli.NewApp() - app.Name = "Gitea" - app.Usage = "A painless self-hosted Git service" - app.Description = `By default, gitea will start serving using the webserver with no + app.Name = "Forgejo" + app.Usage = "Beyond coding. We forge." + app.Description = `By default, forgejo will start serving using the webserver with no arguments - which can alternatively be run by running the subcommand web.` app.Version = Version + formatBuiltWith() app.Commands = []cli.Command{ @@ -180,6 +189,9 @@ func adjustHelpTemplate(originalTemplate string) string { if _, ok := os.LookupEnv("GITEA_CUSTOM"); ok { overridden = "(GITEA_CUSTOM)" } + if _, ok := os.LookupEnv("FORGEJO_CUSTOM"); ok { + overridden = "(FORGEJO_CUSTOM)" + } return fmt.Sprintf(`%s DEFAULT CONFIGURATION: diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 1967d9e79a..a03815473b 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -147,6 +147,9 @@ func SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath string) if giteaCustom, ok := os.LookupEnv("GITEA_CUSTOM"); ok { CustomPath = giteaCustom } + if forgejoCustom, ok := os.LookupEnv("FORGEJO_CUSTOM"); ok { + CustomPath = forgejoCustom + } if len(providedCustom) != 0 { CustomPath = providedCustom } diff --git a/routers/web/admin/config.go b/routers/web/admin/config.go index be662c22ef..1422170924 100644 --- a/routers/web/admin/config.go +++ b/routers/web/admin/config.go @@ -174,10 +174,10 @@ func Config(ctx *context.Context) { envVars := map[string]*envVar{} if len(os.Getenv("GITEA_WORK_DIR")) > 0 { - envVars["GITEA_WORK_DIR"] = &envVar{"GITEA_WORK_DIR", os.Getenv("GITEA_WORK_DIR")} + envVars["FORGEJO_WORK_DIR"] = &envVar{"GITEA_WORK_DIR", os.Getenv("GITEA_WORK_DIR")} } if len(os.Getenv("GITEA_CUSTOM")) > 0 { - envVars["GITEA_CUSTOM"] = &envVar{"GITEA_CUSTOM", os.Getenv("GITEA_CUSTOM")} + envVars["FORGEJO_CUSTOM"] = &envVar{"GITEA_CUSTOM", os.Getenv("GITEA_CUSTOM")} } ctx.Data["EnvVars"] = envVars