MCPcopy Index your code
hub / github.com/go-git/go-git / Validate

Method Validate

config/modules.go:100–118  ·  view source on GitHub ↗

Validate validates the fields and sets the default values.

()

Source from the content-addressed store, hash-verified

98
99// Validate validates the fields and sets the default values.
100func (m *Submodule) Validate() error {
101 if err := validSubmoduleName(m.Name); err != nil {
102 return fmt.Errorf("%w: %q", ErrModuleBadName, m.Name)
103 }
104
105 if m.Path == "" {
106 return ErrModuleEmptyPath
107 }
108
109 if m.URL == "" {
110 return ErrModuleEmptyURL
111 }
112
113 if dotdotPath.MatchString(m.Path) {
114 return ErrModuleBadPath
115 }
116
117 return nil
118}
119
120// validSubmoduleName mirrors canonical Git's check_submodule_name in
121// submodule-config.c [1]: reject empty names and any name with a ".."

Callers 6

TestValidateBadPathMethod · 0.95
TestValidateBadNameMethod · 0.95
TestValidateGoodNameMethod · 0.95
unmarshalSubmodulesFunction · 0.95

Calls 1

validSubmoduleNameFunction · 0.85

Tested by 5

TestValidateBadPathMethod · 0.76
TestValidateBadNameMethod · 0.76
TestValidateGoodNameMethod · 0.76