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

Method loadConfigAuthorAndCommitter

options.go:585–620  ·  view source on GitHub ↗
(r *Repository)

Source from the content-addressed store, hash-verified

583}
584
585func (o *CommitOptions) loadConfigAuthorAndCommitter(r *Repository) error {
586 cfg, err := r.ConfigScoped(config.SystemScope)
587 if err != nil {
588 return err
589 }
590
591 if o.Author == nil && cfg.Author.Email != "" && cfg.Author.Name != "" {
592 o.Author = &object.Signature{
593 Name: cfg.Author.Name,
594 Email: cfg.Author.Email,
595 When: time.Now(),
596 }
597 }
598
599 if o.Committer == nil && cfg.Committer.Email != "" && cfg.Committer.Name != "" {
600 o.Committer = &object.Signature{
601 Name: cfg.Committer.Name,
602 Email: cfg.Committer.Email,
603 When: time.Now(),
604 }
605 }
606
607 if o.Author == nil && cfg.User.Email != "" && cfg.User.Name != "" {
608 o.Author = &object.Signature{
609 Name: cfg.User.Name,
610 Email: cfg.User.Email,
611 When: time.Now(),
612 }
613 }
614
615 if o.Author == nil {
616 return ErrMissingAuthor
617 }
618
619 return nil
620}
621
622var (
623 ErrMissingName = errors.New("name field is required")

Callers 1

ValidateMethod · 0.95

Calls 1

ConfigScopedMethod · 0.80

Tested by

no test coverage detected