diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-06-29 05:30:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-28 23:30:06 +0200 |
commit | b4d0036fc3e0657806e550431bf1d5420349472a (patch) | |
tree | ee2f40e380c5c2fb53f258c38735a5ef8313b9df /main.go | |
parent | 6daf21c9b722e31ea5e3b1ec48caa69327580abd (diff) | |
download | gitea-b4d0036fc3e0657806e550431bf1d5420349472a.tar.gz gitea-b4d0036fc3e0657806e550431bf1d5420349472a.zip |
Do not prepare oauth2 config if it is not enabled, do not write config in some sub-commands (#25567)
Ref:
* https://github.com/go-gitea/gitea/issues/25377#issuecomment-1609757289
And some sub-commands like "generate" / "docs", they do not need to use
the ini config
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -87,25 +87,31 @@ func main() { app.Description = `By default, Gitea will start serving using the web-server with no argument, which can alternatively be run by running the subcommand "web".` app.Version = Version + formatBuiltWith() app.EnableBashCompletion = true - app.Commands = []cli.Command{ + + // these sub-commands need to use config file + subCmdWithIni := []cli.Command{ cmd.CmdWeb, cmd.CmdServ, cmd.CmdHook, cmd.CmdDump, - cmd.CmdCert, cmd.CmdAdmin, - cmd.CmdGenerate, cmd.CmdMigrate, cmd.CmdKeys, cmd.CmdConvert, cmd.CmdDoctor, cmd.CmdManager, - cmd.Cmdembedded, + cmd.CmdEmbedded, cmd.CmdMigrateStorage, - cmd.CmdDocs, cmd.CmdDumpRepository, cmd.CmdRestoreRepository, cmd.CmdActions, + cmdHelp, // TODO: the "help" sub-command was used to show the more information for "work path" and "custom config", in the future, it should avoid doing so + } + // these sub-commands do not need the config file, and they do not depend on any path or environment variable. + subCmdStandalone := []cli.Command{ + cmd.CmdCert, + cmd.CmdGenerate, + cmd.CmdDocs, } // shared configuration flags, they are for global and for each sub-command at the same time @@ -134,10 +140,11 @@ func main() { app.Action = prepareWorkPathAndCustomConf(cmd.CmdWeb.Action) app.HideHelp = true // use our own help action to show helps (with more information like default config) app.Before = cmd.PrepareConsoleLoggerLevel(log.INFO) - app.Commands = append(app.Commands, cmdHelp) - for i := range app.Commands { - prepareSubcommands(&app.Commands[i], globalFlags) + for i := range subCmdWithIni { + prepareSubcommands(&subCmdWithIni[i], globalFlags) } + app.Commands = append(app.Commands, subCmdWithIni...) + app.Commands = append(app.Commands, subCmdStandalone...) err := app.Run(os.Args) if err != nil { |