You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmd.go 888B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. // Package cmd provides subcommands to the gitea binary - such as "web" or
  5. // "admin".
  6. package cmd
  7. import (
  8. "errors"
  9. "fmt"
  10. "code.gitea.io/gitea/models"
  11. "code.gitea.io/gitea/modules/setting"
  12. "github.com/urfave/cli"
  13. )
  14. // argsSet checks that all the required arguments are set. args is a list of
  15. // arguments that must be set in the passed Context.
  16. func argsSet(c *cli.Context, args ...string) error {
  17. for _, a := range args {
  18. if !c.IsSet(a) {
  19. return errors.New(a + " is not set")
  20. }
  21. }
  22. return nil
  23. }
  24. func initDB() error {
  25. setting.NewContext()
  26. models.LoadConfigs()
  27. setting.NewXORMLogService(false)
  28. if err := models.SetEngine(); err != nil {
  29. return fmt.Errorf("models.SetEngine: %v", err)
  30. }
  31. return nil
  32. }