code.gitea.io/gitea@v1.19.3/modules/setting/git.go (about)

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