Move redirects to upstream

This commit is contained in:
video-prize-ranch 2023-02-25 21:30:05 -05:00
parent ac5d6e38fa
commit 0169816854
No known key found for this signature in database
3 changed files with 57 additions and 40 deletions

View file

@ -25,9 +25,11 @@ const redirectsConfig = "_redirects"
func (o *Options) GetRedirects(giteaClient *gitea.Client, redirectsCache cache.SetGetKey) []Redirect {
var redirects []Redirect
// Check for cached redirects
if cachedValue, ok := redirectsCache.Get(o.TargetOwner + "/" + o.TargetRepo + "/" + o.TargetBranch); ok {
redirects = cachedValue.([]Redirect)
} else {
// Get _redirects file and parse
body, err := giteaClient.GiteaRawContent(o.TargetOwner, o.TargetRepo, o.TargetBranch, redirectsConfig)
if err == nil {
for _, line := range strings.Split(string(body), "\n") {