From 68b568c014be857d6700253198a7dddc0af23b94 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sun, 31 Dec 2023 14:15:39 +0100 Subject: [PATCH] Allow using the CNAME as the repository name --- repo.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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,