Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

restore_repo.go 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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"
  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, r",
  19. Value: "./data",
  20. Usage: "Repository dir path to restore from",
  21. },
  22. cli.StringFlag{
  23. Name: "owner_name",
  24. Value: "",
  25. Usage: "Restore destination owner name",
  26. },
  27. cli.StringFlag{
  28. Name: "repo_name",
  29. Value: "",
  30. Usage: "Restore destination repository name",
  31. },
  32. cli.StringFlag{
  33. Name: "units",
  34. Value: "",
  35. Usage: `Which items will be restored, one or more units should be separated as comma.
  36. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.`,
  37. },
  38. cli.BoolFlag{
  39. Name: "validation",
  40. Usage: "Sanity check the content of the files before trying to load them",
  41. },
  42. },
  43. }
  44. func runRestoreRepository(c *cli.Context) error {
  45. ctx, cancel := installSignals()
  46. defer cancel()
  47. setting.Init(&setting.Options{})
  48. var units []string
  49. if s := c.String("units"); s != "" {
  50. units = strings.Split(s, ",")
  51. }
  52. extra := private.RestoreRepo(
  53. ctx,
  54. c.String("repo_dir"),
  55. c.String("owner_name"),
  56. c.String("repo_name"),
  57. units,
  58. c.Bool("validation"),
  59. )
  60. return handleCliResponseExtra(extra)
  61. }