MCPcopy Index your code
hub / github.com/cli/cli / DigestAlgForRef

Function DigestAlgForRef

pkg/cmd/release/shared/fetch.go:177–184  ·  view source on GitHub ↗

DigestAlgForRef returns the digest algorithm name corresponding to the given git ref SHA. SHA-1 git object IDs are 40 hex characters and SHA-256 git object IDs are 64 hex characters. Unknown lengths default to "sha1" to preserve backwards-compatible behavior.

(digest string)

Source from the content-addressed store, hash-verified

175// object IDs are 64 hex characters. Unknown lengths default to "sha1" to
176// preserve backwards-compatible behavior.
177func DigestAlgForRef(digest string) string {
178 switch len(digest) {
179 case 64:
180 return "sha256"
181 default:
182 return "sha1"
183 }
184}
185
186// FetchRelease finds a published repository release by its tagName, or a draft release by its pending tag name.
187func FetchRelease(ctx context.Context, httpClient *http.Client, repo ghrepo.Interface, tagName string) (*Release, error) {

Callers 3

verifyRunFunction · 0.92
verifyAssetRunFunction · 0.92
TestDigestAlgForRefFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDigestAlgForRefFunction · 0.68