MCPcopy Create free account
hub / github.com/celer-pkg/celer / IsFullCommitHash

Function IsFullCommitHash

pkgs/git/local.go:191–203  ·  view source on GitHub ↗

IsFullCommitHash checks if a string looks like a full git commit hash (40 hex chars)

(ref string)

Source from the content-addressed store, hash-verified

189
190// IsFullCommitHash checks if a string looks like a full git commit hash (40 hex chars)
191func 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

Callers 2

resolveGitRefFunction · 0.92
CheckIfRefMatchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected