IsFullCommitHash checks if a string looks like a full git commit hash (40 hex chars)
(ref string)
| 189 | |
| 190 | // IsFullCommitHash checks if a string looks like a full git commit hash (40 hex chars) |
| 191 | func IsFullCommitHash(ref string) bool { |
| 192 | if len(ref) != 40 { |
| 193 | return false |
| 194 | } |
| 195 | |
| 196 | for _, b := range []byte(ref) { |
| 197 | if !((b >= '0' && b <= '9') || (b >= 'a' && b <= 'f')) { |
| 198 | return false |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | return true |
| 203 | } |
| 204 | |
| 205 | // CheckIfRefMatches checks whether the local checkout matches the expected ref. |
| 206 | // It returns an empty string on match, or a human-readable mismatch reason when |
no outgoing calls
no test coverage detected