This commit is contained in:
6543 2022-11-11 19:03:17 +01:00
parent 9a44e26da7
commit 6bc79e5ebf
No known key found for this signature in database
GPG key ID: B8BE6D610E61C862
2 changed files with 49 additions and 5 deletions

View file

@ -93,7 +93,7 @@ func Handler(mainDomainSuffix, rawDomain string,
// tryBranch checks if a branch exists and populates the target variables. If canonicalLink is non-empty, it will
// also disallow search indexing and add a Link header to the canonical URL.
// TODO: move into external func to not alert vars indirectly
tryBranch := func(log zerolog.Logger, repo, branch string, _path []string, canonicalLink string) bool {
tryBranch1 := func(log zerolog.Logger, repo, branch string, _path []string, canonicalLink string) bool {
if repo == "" {
log.Debug().Msg("tryBranch: repo == ''")
return false
@ -150,13 +150,14 @@ func Handler(mainDomainSuffix, rawDomain string,
// raw.codeberg.org/example/myrepo/@main/index.html
if len(pathElements) > 2 && strings.HasPrefix(pathElements[2], "@") {
log.Debug().Msg("raw domain preparations, now trying with specified branch")
if tryBranch(log,
targetRepo, pathElements[2][1:], pathElements[3:],
if newRepo, newPath, newBranch, newTimestamp, works := tryBranch2(log, ctx, giteaClient,
targetOwner, targetRepo, pathElements[2][1:], pathElements[3:],
giteaRoot+"/"+targetOwner+"/"+targetRepo+"/src/branch/%b/%p",
) {
); works {
targetOptions.BranchTimestamp = *newTimestamp
log.Debug().Msg("tryBranch, now trying upstream 1")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost,
targetOptions, targetOwner, targetRepo, targetBranch, targetPath,
targetOptions, targetOwner, newRepo, newBranch, newPath,
canonicalDomainCache)
return
}