mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Merge setting.InitXXX into one function with options (#24389)
This PR will merge 3 Init functions on setting packages as 1 and introduce an options struct.
This commit is contained in:
parent
a2fe68e50b
commit
377a0a20f0
28 changed files with 104 additions and 137 deletions
|
@ -42,8 +42,7 @@ func runGenerateActionsRunnerToken(c *cli.Context) error {
|
|||
ctx, cancel := installSignals()
|
||||
defer cancel()
|
||||
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
|
||||
scope := c.String("scope")
|
||||
|
||||
|
|
|
@ -57,8 +57,7 @@ func confirm() (bool, error) {
|
|||
}
|
||||
|
||||
func initDB(ctx context.Context) error {
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
setting.LoadDBSetting()
|
||||
setting.InitSQLLog(false)
|
||||
|
||||
|
|
|
@ -87,8 +87,7 @@ func runRecreateTable(ctx *cli.Context) error {
|
|||
golog.SetPrefix("")
|
||||
golog.SetOutput(log.NewLoggerAsWriter("INFO", log.GetLogger(log.DEFAULT)))
|
||||
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
setting.LoadDBSetting()
|
||||
|
||||
setting.Log.EnableXORMLog = ctx.Bool("debug")
|
||||
|
|
|
@ -185,8 +185,7 @@ func runDump(ctx *cli.Context) error {
|
|||
}
|
||||
fileName += "." + outType
|
||||
}
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
|
||||
// make sure we are logging to the console no matter what the configuration tells us do to
|
||||
// FIXME: don't use CfgProvider directly
|
||||
|
|
|
@ -106,8 +106,9 @@ func initEmbeddedExtractor(c *cli.Context) error {
|
|||
log.DelNamedLogger(log.DEFAULT)
|
||||
|
||||
// Read configuration file
|
||||
setting.InitProviderAllowEmpty()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{
|
||||
AllowEmpty: true,
|
||||
})
|
||||
|
||||
patterns, err := compileCollectPatterns(c.Args())
|
||||
if err != nil {
|
||||
|
|
|
@ -16,8 +16,7 @@ func runSendMail(c *cli.Context) error {
|
|||
ctx, cancel := installSignals()
|
||||
defer cancel()
|
||||
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
|
||||
if err := argsSet(c, "title"); err != nil {
|
||||
return err
|
||||
|
|
|
@ -7,14 +7,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
func init() {
|
||||
setting.SetCustomPathAndConf("", "", "")
|
||||
setting.InitProviderAndLoadCommonSettingsForTest()
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
unittest.MainTest(m, &unittest.TestOptions{
|
||||
GiteaRootPath: "..",
|
||||
|
|
|
@ -51,8 +51,7 @@ func runRestoreRepository(c *cli.Context) error {
|
|||
ctx, cancel := installSignals()
|
||||
defer cancel()
|
||||
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
var units []string
|
||||
if s := c.String("units"); s != "" {
|
||||
units = strings.Split(s, ",")
|
||||
|
|
|
@ -62,8 +62,7 @@ func setup(ctx context.Context, debug bool) {
|
|||
} else {
|
||||
_ = log.NewLogger(1000, "console", "console", `{"level":"fatal","stacktracelevel":"NONE","stderr":true}`)
|
||||
}
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
if debug {
|
||||
setting.RunMode = "dev"
|
||||
}
|
||||
|
|
|
@ -177,8 +177,7 @@ func runWeb(ctx *cli.Context) error {
|
|||
|
||||
log.Info("Global init")
|
||||
// Perform global initialization
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
routers.GlobalInitInstalled(graceful.GetManager().HammerContext())
|
||||
|
||||
// We check that AppDataPath exists here (it should have been created during installation)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue