getRepoDefaultBranchCached wraps getRepoDefaultBranch with a cache to avoid repeating identical GitHub API calls during batched update runs.
(ctx context.Context, repo string)
| 324 | // getRepoDefaultBranchCached wraps getRepoDefaultBranch with a cache to avoid |
| 325 | // repeating identical GitHub API calls during batched update runs. |
| 326 | func 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. |
no test coverage detected