Allow using the CNAME as the repository name

This commit is contained in:
PapaTutuWawa 2023-12-31 14:15:39 +01:00
parent 470d759797
commit 68b568c014

14
repo.go
View File

@ -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,