Validate validates the RefSpec
()
| 30 | |
| 31 | // Validate validates the RefSpec |
| 32 | func (s RefSpec) Validate() error { |
| 33 | spec := string(s) |
| 34 | if strings.Count(spec, refSpecSeparator) != 1 { |
| 35 | return ErrRefSpecMalformedSeparator |
| 36 | } |
| 37 | |
| 38 | sep := strings.Index(spec, refSpecSeparator) |
| 39 | if sep == len(spec)-1 { |
| 40 | return ErrRefSpecMalformedSeparator |
| 41 | } |
| 42 | |
| 43 | ws := strings.Count(spec[0:sep], refSpecWildcard) |
| 44 | wd := strings.Count(spec[sep+1:], refSpecWildcard) |
| 45 | if ws == wd && ws < 2 && wd < 2 { |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | return ErrRefSpecMalformedWildcard |
| 50 | } |
| 51 | |
| 52 | // IsForceUpdate returns if update is allowed in non fast-forward merges. |
| 53 | func (s RefSpec) IsForceUpdate() bool { |