prow/repoowners/repoowners.go
func (c *Client) LoadRepoAliases(org, repo, base string) (RepoAliases, error) {
	log := c.logger.WithFields(logrus.Fields{"org": org, "repo": repo, "base": base})
	cloneRef := fmt.Sprintf("%s/%s", org, repo)
	fullName := fmt.Sprintf("%s:%s", cloneRef, base)

	sha, err := c.ghc.GetRef(org, repo, fmt.Sprintf("heads/%s", base))
	if err != nil {
		return nil, fmt.Errorf("failed to get current SHA for %s: %v", fullName, err)
	}

	c.lock.Lock()
	defer c.lock.Unlock()
	entry, ok := c.cache[fullName]
	if !ok || entry.sha != sha {
		// entry is non-existent or stale.
		gitRepo, err := c.git.Clone(cloneRef)
		if err != nil {
			return nil, fmt.Errorf("failed to clone %s: %v", cloneRef, err)
		}
		defer gitRepo.Clean()
		if err := gitRepo.Checkout(base); err != nil {
			return nil, err
		}

		entry.aliases = loadAliasesFrom(gitRepo.Dir, log)
		entry.sha = sha
		c.cache[fullName] = entry
	}

	return entry.aliases, nil
}
func (c *Client) LoadRepoAliases(org, repo, base string) (RepoAliases, error) {
	log := c.logger.WithFields(logrus.Fields{"org": org, "repo": repo, "base": base})
	cloneRef := fmt.Sprintf("%s/%s", org, repo)
	fullName := fmt.Sprintf("%s:%s", cloneRef, base)

	sha, err := c.ghc.GetRef(org, repo, fmt.Sprintf("heads/%s", base))
	if err != nil {
		return nil, fmt.Errorf("failed to get current SHA for %s: %v", fullName, err)
	}

	c.lock.Lock()
	defer c.lock.Unlock()
	entry, ok := c.cache[fullName]
	if !ok || entry.sha != sha {
		// entry is non-existent or stale.
		gitRepo, err := c.git.Clone(cloneRef)
		if err != nil {
			return nil, fmt.Errorf("failed to clone %s: %v", cloneRef, err)
		}
		defer gitRepo.Clean()
		if err := gitRepo.Checkout(base); err != nil {
			return nil, err
		}

		entry.aliases = loadAliasesFrom(gitRepo.Dir, log)
		entry.sha = sha
		c.cache[fullName] = entry
	}

	return entry.aliases, nil
}
// LoadRepoAliases returns an up-to-date RepoAliases struct for the specified repo.
// If the repo does not have an aliases file then an empty alias map is returned with no error.
// Note: The returned RepoAliases should be treated as read only.