Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package cmd
  4. import (
  5. "strings"
  6. "code.gitea.io/gitea/modules/private"
  7. "code.gitea.io/gitea/modules/setting"
  8. "github.com/urfave/cli/v2"
  9. )
  10. // CmdRestoreRepository represents the available restore a repository sub-command.
  11. var CmdRestoreRepository = &cli.Command{
  12. Name: "restore-repo",
  13. Usage: "Restore the repository from disk",
  14. Description: "This is a command for restoring the repository data.",
  15. Action: runRestoreRepository,
  16. Flags: []cli.Flag{
  17. &cli.StringFlag{
  18. Name: "repo_dir",
  19. Aliases: []string{"r"},
  20. Value: "./data",
  21. Usage: "Repository dir path to restore from",
  22. },
  23. &cli.StringFlag{
  24. Name: "owner_name",
  25. Value: "",
  26. Usage: "Restore destination owner name",
  27. },
  28. &cli.StringFlag{
  29. Name: "repo_name",
  30. Value: "",
  31. Usage: "Restore destination repository name",
  32. },
  33. &cli.StringFlag{
  34. Name: "units",
  35. Value: "",
  36. Usage: `Which items will be restored, one or more units should be separated as comma.
  37. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.`,
  38. },
  39. &cli.BoolFlag{
  40. Name: "validation",
  41. Usage: "Sanity check the content of the files before trying to load them",
  42. },
  43. },
  44. }
  45. func runRestoreRepository(c *cli.Context) error {
  46. ctx, cancel := installSignals()
  47. defer cancel()
  48. setting.MustInstalled()
  49. var units []string
  50. if s := c.String("units"); s != "" {
  51. units = strings.Split(s, ",")
  52. }
  53. extra := private.RestoreRepo(
  54. ctx,
  55. c.String("repo_dir"),
  56. c.String("owner_name"),
  57. c.String("repo_name"),
  58. units,
  59. c.Bool("validation"),
  60. )
  61. return handleCliResponseExtra(extra)
  62. }