MCPcopy
hub / github.com/github/github-mcp-server / looksLikeSHA

Function looksLikeSHA

pkg/github/repositories_helper.go:166–176  ·  view source on GitHub ↗

looksLikeSHA returns true if the string appears to be a Git commit SHA. A SHA is a 40-character hexadecimal string.

(s string)

Source from the content-addressed store, hash-verified

164// looksLikeSHA returns true if the string appears to be a Git commit SHA.
165// A SHA is a 40-character hexadecimal string.
166func 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.

Callers 3

resolveGitReferenceFunction · 0.85
expandRepoResourceURIFunction · 0.85
Test_looksLikeSHAFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_looksLikeSHAFunction · 0.68