MCPcopy
hub / github.com/go-git/go-git / loadConfigAuthorAndCommitter

Method loadConfigAuthorAndCommitter

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

Source from the content-addressed store, hash-verified

615}
616
617func (o *CommitOptions) loadConfigAuthorAndCommitter(r *Repository) error {
618 cfg, err := r.ConfigScoped(config.SystemScope)
619 if err != nil {
620 return err
621 }
622
623 if o.Author == nil && cfg.Author.Email != "" && cfg.Author.Name != "" {
624 o.Author = &object.Signature{
625 Name: cfg.Author.Name,
626 Email: cfg.Author.Email,
627 When: time.Now(),
628 }
629 }
630
631 if o.Committer == nil && cfg.Committer.Email != "" && cfg.Committer.Name != "" {
632 o.Committer = &object.Signature{
633 Name: cfg.Committer.Name,
634 Email: cfg.Committer.Email,
635 When: time.Now(),
636 }
637 }
638
639 if o.Author == nil && cfg.User.Email != "" && cfg.User.Name != "" {
640 o.Author = &object.Signature{
641 Name: cfg.User.Name,
642 Email: cfg.User.Email,
643 When: time.Now(),
644 }
645 }
646
647 if o.Author == nil {
648 return ErrMissingAuthor
649 }
650
651 return nil
652}
653
654var (
655 ErrMissingName = errors.New("name field is required")

Callers 1

ValidateMethod · 0.95

Calls 1

ConfigScopedMethod · 0.80

Tested by

no test coverage detected