Validate validates the fields and sets the default values.
()
| 597 | |
| 598 | // Validate validates the fields and sets the default values. |
| 599 | func (c *RemoteConfig) Validate() error { |
| 600 | if c.Name == "" { |
| 601 | return ErrRemoteConfigEmptyName |
| 602 | } |
| 603 | |
| 604 | if len(c.URLs) == 0 { |
| 605 | return ErrRemoteConfigEmptyURL |
| 606 | } |
| 607 | |
| 608 | for _, r := range c.Fetch { |
| 609 | if err := r.Validate(); err != nil { |
| 610 | return err |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | if len(c.Fetch) == 0 { |
| 615 | c.Fetch = []RefSpec{RefSpec(fmt.Sprintf(DefaultFetchRefSpec, c.Name))} |
| 616 | } |
| 617 | |
| 618 | return plumbing.NewRemoteHEADReferenceName(c.Name).Validate() |
| 619 | } |
| 620 | |
| 621 | func (c *RemoteConfig) unmarshal(s *format.Subsection) error { |
| 622 | c.raw = s |