diff --git a/repo.go b/repo.go index 9de1f4f..26b2365 100644 --- a/repo.go +++ b/repo.go @@ -24,6 +24,10 @@ func makePageCacheKey(domain, path string) string { return domain + "/" + path } +/// Try to find the repository with name @reponame of the user @username. If @cname +/// is not "", then it also verifies that the repository contains a "CNAME" with +/// the value of @cname as its content. @host, @domain, and @path are passed for +/// caching on success. func lookupRepositoryAndCache(username, reponame, host, domain, path, cname string, giteaClient *gitea.Client) (*gitea.Repository, error) { log.Debugf("Looking up repository %s/%s", username, reponame) repo, _, err := giteaClient.GetRepo(username, reponame) @@ -96,10 +100,16 @@ func RepoFromPath(username, host, cname, path string, giteaClient *gitea.Client) } } - log.Debugf("Trying repository pages") + // Allow naming the repository "example.org" + reponame := domain + if cname != "" { + reponame = cname; + } + + log.Debugf("Trying repository %s/%s", username, reponame) repo, err := lookupRepositoryAndCache( username, - domain, + reponame, host, domain, path,