MCPcopy Create free account
hub / github.com/go-git/go-git / Paths

Function Paths

config/config.go:191–214  ·  view source on GitHub ↗

Paths returns the config file location for a given scope.

(scope Scope)

Source from the content-addressed store, hash-verified

189
190// Paths returns the config file location for a given scope.
191func Paths(scope Scope) ([]string, error) {
192 var files []string
193 switch scope {
194 case GlobalScope:
195 xdg := os.Getenv("XDG_CONFIG_HOME")
196 if xdg != "" {
197 files = append(files, filepath.Join(xdg, "git/config"))
198 }
199
200 home, err := os.UserHomeDir()
201 if err != nil {
202 return nil, err
203 }
204
205 files = append(files,
206 filepath.Join(home, ".gitconfig"),
207 filepath.Join(home, ".config/git/config"),
208 )
209 case SystemScope:
210 files = append(files, "/etc/gitconfig")
211 }
212
213 return files, nil
214}
215
216// Validate validates the fields and sets the default values.
217func (c *Config) Validate() error {

Callers 1

LoadConfigFunction · 0.85

Calls 1

JoinMethod · 0.80

Tested by

no test coverage detected