MCPcopy Create free account
hub / github.com/github/gh-aw / getLatestBranchCommitSHACached

Function getLatestBranchCommitSHACached

pkg/cli/update_workflows.go:343–357  ·  view source on GitHub ↗

getLatestBranchCommitSHACached wraps getLatestBranchCommitSHA with a cache keyed by repo+branch to reduce repeated branch-head API lookups.

(ctx context.Context, repo, branch string)

Source from the content-addressed store, hash-verified

341// getLatestBranchCommitSHACached wraps getLatestBranchCommitSHA with a cache
342// keyed by repo+branch to reduce repeated branch-head API lookups.
343func getLatestBranchCommitSHACached(ctx context.Context, repo, branch string) (string, error) {
344 key := repoBranchKey{repo: repo, branch: branch}
345 if cached, ok := branchCommitCache.Load(key); ok {
346 if sha, isString := cached.(string); isString {
347 return sha, nil
348 }
349 }
350
351 sha, err := getLatestBranchCommitSHA(ctx, repo, branch)
352 if err != nil {
353 return "", err
354 }
355 branchCommitCache.Store(key, sha)
356 return sha, nil
357}
358
359// fetchPublicGitHubAPI makes an unauthenticated GET request to the GitHub public
360// REST API. This is used as a fallback when the current token (e.g. an enterprise

Callers 2

resolveLatestRefFunction · 0.85

Calls 2

getLatestBranchCommitSHAFunction · 0.85
LoadMethod · 0.80

Tested by

no test coverage detected