loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

wxiaoguang and committed by
GitHub
b4d0036f 6daf21c9

+21 -10
+2 -2
cmd/embedded.go
··· 22 22 "github.com/urfave/cli" 23 23 ) 24 24 25 - // Cmdembedded represents the available extract sub-command. 25 + // CmdEmbedded represents the available extract sub-command. 26 26 var ( 27 - Cmdembedded = cli.Command{ 27 + CmdEmbedded = cli.Command{ 28 28 Name: "embedded", 29 29 Usage: "Extract embedded resources", 30 30 Description: "A command for extracting embedded resources, like templates and images",
+15 -8
main.go
··· 87 87 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".` 88 88 app.Version = Version + formatBuiltWith() 89 89 app.EnableBashCompletion = true 90 - app.Commands = []cli.Command{ 90 + 91 + // these sub-commands need to use config file 92 + subCmdWithIni := []cli.Command{ 91 93 cmd.CmdWeb, 92 94 cmd.CmdServ, 93 95 cmd.CmdHook, 94 96 cmd.CmdDump, 95 - cmd.CmdCert, 96 97 cmd.CmdAdmin, 97 - cmd.CmdGenerate, 98 98 cmd.CmdMigrate, 99 99 cmd.CmdKeys, 100 100 cmd.CmdConvert, 101 101 cmd.CmdDoctor, 102 102 cmd.CmdManager, 103 - cmd.Cmdembedded, 103 + cmd.CmdEmbedded, 104 104 cmd.CmdMigrateStorage, 105 - cmd.CmdDocs, 106 105 cmd.CmdDumpRepository, 107 106 cmd.CmdRestoreRepository, 108 107 cmd.CmdActions, 108 + 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 109 + } 110 + // these sub-commands do not need the config file, and they do not depend on any path or environment variable. 111 + subCmdStandalone := []cli.Command{ 112 + cmd.CmdCert, 113 + cmd.CmdGenerate, 114 + cmd.CmdDocs, 109 115 } 110 116 111 117 // shared configuration flags, they are for global and for each sub-command at the same time ··· 134 140 app.Action = prepareWorkPathAndCustomConf(cmd.CmdWeb.Action) 135 141 app.HideHelp = true // use our own help action to show helps (with more information like default config) 136 142 app.Before = cmd.PrepareConsoleLoggerLevel(log.INFO) 137 - app.Commands = append(app.Commands, cmdHelp) 138 - for i := range app.Commands { 139 - prepareSubcommands(&app.Commands[i], globalFlags) 143 + for i := range subCmdWithIni { 144 + prepareSubcommands(&subCmdWithIni[i], globalFlags) 140 145 } 146 + app.Commands = append(app.Commands, subCmdWithIni...) 147 + app.Commands = append(app.Commands, subCmdStandalone...) 141 148 142 149 err := app.Run(os.Args) 143 150 if err != nil {
+4
modules/setting/oauth2.go
··· 116 116 return 117 117 } 118 118 119 + if !OAuth2.Enable { 120 + return 121 + } 122 + 119 123 OAuth2.JWTSecretBase64 = loadSecret(rootCfg.Section("oauth2"), "JWT_SECRET_URI", "JWT_SECRET") 120 124 121 125 if !filepath.IsAbs(OAuth2.JWTSigningPrivateKeyFile) {