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

Method ConfigScoped

repository.go:566–594  ·  view source on GitHub ↗

ConfigScoped returns the repository config, merged with requested scope and lower. For example if, config.GlobalScope is given the local and global config are returned merged in one config value.

(scope config.Scope)

Source from the content-addressed store, hash-verified

564// lower. For example if, config.GlobalScope is given the local and global config
565// are returned merged in one config value.
566func (r *Repository) ConfigScoped(scope config.Scope) (*config.Config, error) {
567 // TODO(mcuadros): v6, add this as ConfigOptions.Scoped
568
569 var err error
570 system := config.NewConfig()
571 if scope >= config.SystemScope {
572 system, err = config.LoadConfig(config.SystemScope)
573 if err != nil {
574 return nil, err
575 }
576 }
577
578 global := config.NewConfig()
579 if scope >= config.GlobalScope {
580 global, err = config.LoadConfig(config.GlobalScope)
581 if err != nil {
582 return nil, err
583 }
584 }
585
586 local, err := r.Storer.Config()
587 if err != nil {
588 return nil, err
589 }
590
591 _ = mergo.Merge(global, system)
592 _ = mergo.Merge(local, global)
593 return local, nil
594}
595
596// Remote return a remote if exists
597func (r *Repository) Remote(name string) (*Remote, error) {

Callers 3

TestConfigScopedMethod · 0.80
loadConfigTaggerMethod · 0.80

Calls 2

MergeMethod · 0.80
ConfigMethod · 0.65

Tested by 1

TestConfigScopedMethod · 0.64