From 086c14c75d06c43a08c5de193101d42871c5d9e8 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 5f528f0a25d0418b9c4ebdc4effa8d2b869be0d8) (cherry picked from commit 65146bfbcd1102a8e182ac6967804659fea9651f) (cherry picked from commit 393eede84a856ae4545c2f5695eba5cbf4d57fbb) (cherry picked from commit df68ae9d1f00b4c465cd717f8a91a8a94aae5703) (cherry picked from commit 2f05b0cc1fea60cb685fc10f083ce0053641bbe5) (cherry picked from commit 71d2c21c8103e21b113898d6c8fbf6f7156fc5d7) --- 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 f004d58bea..06343b2698 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{ @@ -178,6 +187,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 dfe8dcfa1c..4dba0427cd 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -167,6 +167,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 075fb423dc..eb90bb211b 100644 --- a/routers/web/admin/config.go +++ b/routers/web/admin/config.go @@ -175,10 +175,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