looksLikeSHA returns true if the string appears to be a Git commit SHA. A SHA is a 40-character hexadecimal string.
(s string)
| 164 | // looksLikeSHA returns true if the string appears to be a Git commit SHA. |
| 165 | // A SHA is a 40-character hexadecimal string. |
| 166 | func looksLikeSHA(s string) bool { |
| 167 | if len(s) != 40 { |
| 168 | return false |
| 169 | } |
| 170 | for _, c := range s { |
| 171 | if (c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F') { |
| 172 | return false |
| 173 | } |
| 174 | } |
| 175 | return true |
| 176 | } |
| 177 | |
| 178 | // resolveGitReference takes a user-provided ref and sha and resolves them into a |
| 179 | // definitive commit SHA and its corresponding fully-qualified reference. |
no outgoing calls