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.

git.go 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import (
  5. "path/filepath"
  6. "time"
  7. "code.gitea.io/gitea/modules/log"
  8. )
  9. // Git settings
  10. var Git = struct {
  11. Path string
  12. HomePath string
  13. DisableDiffHighlight bool
  14. MaxGitDiffLines int
  15. MaxGitDiffLineCharacters int
  16. MaxGitDiffFiles int
  17. CommitsRangeSize int // CommitsRangeSize the default commits range size
  18. BranchesRangeSize int // BranchesRangeSize the default branches range size
  19. VerbosePush bool
  20. VerbosePushDelay time.Duration
  21. GCArgs []string `ini:"GC_ARGS" delim:" "`
  22. EnableAutoGitWireProtocol bool
  23. PullRequestPushMessage bool
  24. LargeObjectThreshold int64
  25. DisableCoreProtectNTFS bool
  26. DisablePartialClone bool
  27. Timeout struct {
  28. Default int
  29. Migrate int
  30. Mirror int
  31. Clone int
  32. Pull int
  33. GC int `ini:"GC"`
  34. } `ini:"git.timeout"`
  35. }{
  36. DisableDiffHighlight: false,
  37. MaxGitDiffLines: 1000,
  38. MaxGitDiffLineCharacters: 5000,
  39. MaxGitDiffFiles: 100,
  40. CommitsRangeSize: 50,
  41. BranchesRangeSize: 20,
  42. VerbosePush: true,
  43. VerbosePushDelay: 5 * time.Second,
  44. GCArgs: []string{},
  45. EnableAutoGitWireProtocol: true,
  46. PullRequestPushMessage: true,
  47. LargeObjectThreshold: 1024 * 1024,
  48. DisablePartialClone: false,
  49. Timeout: struct {
  50. Default int
  51. Migrate int
  52. Mirror int
  53. Clone int
  54. Pull int
  55. GC int `ini:"GC"`
  56. }{
  57. Default: 360,
  58. Migrate: 600,
  59. Mirror: 300,
  60. Clone: 300,
  61. Pull: 300,
  62. GC: 60,
  63. },
  64. }
  65. func newGit() {
  66. sec := Cfg.Section("git")
  67. if err := sec.MapTo(&Git); err != nil {
  68. log.Fatal("Failed to map Git settings: %v", err)
  69. }
  70. Git.HomePath = sec.Key("HOME_PATH").MustString("home")
  71. if !filepath.IsAbs(Git.HomePath) {
  72. Git.HomePath = filepath.Join(AppDataPath, Git.HomePath)
  73. } else {
  74. Git.HomePath = filepath.Clean(Git.HomePath)
  75. }
  76. }