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

Function getRepoDefaultBranchCached

pkg/cli/update_workflows.go:326–339  ·  view source on GitHub ↗

getRepoDefaultBranchCached wraps getRepoDefaultBranch with a cache to avoid repeating identical GitHub API calls during batched update runs.

(ctx context.Context, repo string)

Source from the content-addressed store, hash-verified

324// getRepoDefaultBranchCached wraps getRepoDefaultBranch with a cache to avoid
325// repeating identical GitHub API calls during batched update runs.
326func getRepoDefaultBranchCached(ctx context.Context, repo string) (string, error) {
327 if cached, ok := defaultBranchCache.Load(repo); ok {
328 if branch, isString := cached.(string); isString {
329 return branch, nil
330 }
331 }
332
333 branch, err := getRepoDefaultBranch(ctx, repo)
334 if err != nil {
335 return "", err
336 }
337 defaultBranchCache.Store(repo, branch)
338 return branch, nil
339}
340
341// getLatestBranchCommitSHACached wraps getLatestBranchCommitSHA with a cache
342// keyed by repo+branch to reduce repeated branch-head API lookups.

Callers 2

resolveDefaultBranchRefFunction · 0.85

Calls 2

getRepoDefaultBranchFunction · 0.85
LoadMethod · 0.80

Tested by

no test coverage detected