defined branches are requested before the default branch on the default repo

This commit is contained in:
Simon Vieille 2022-11-14 15:46:48 +01:00
parent dfea70b5cc
commit 51954417cd
No known key found for this signature in database
GPG Key ID: 579388D585F70417

View File

@ -103,7 +103,7 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
// Try to use the defaultPagesRepo on its default branch
// example.codeberg.page/index.html
log.Debug().Msg("main domain preparations, now trying with default repo/branch")
log.Debug().Msg("main domain preparations, now trying with default repo")
if targetOpt, works := tryBranch(log, ctx, giteaClient, &upstream.Options{
TryIndexPages: true,
TargetOwner: targetOwner,
@ -117,6 +117,18 @@ func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gite
}
}
log.Debug().Msg("main domain preparations, now trying with default repo/branch")
if targetOpt, works := tryBranch(log, ctx, giteaClient, &upstream.Options{
TryIndexPages: true,
TargetOwner: targetOwner,
TargetRepo: defaultPagesRepo,
TargetPath: path.Join(pathElements...),
}, false); works {
log.Debug().Msg("tryBranch, now trying upstream 6")
tryUpstream(ctx, giteaClient, mainDomainSuffix, trimmedHost, targetOpt, canonicalDomainCache)
return
}
// Couldn't find a valid repo/branch
html.ReturnErrorPage(ctx,
fmt.Sprintf("couldn't find a valid repo[%s]", targetRepo),