diff --git a/server/upstream/gitea.go b/server/upstream/gitea.go index 34653c4..f1ffd06 100644 --- a/server/upstream/gitea.go +++ b/server/upstream/gitea.go @@ -20,7 +20,9 @@ const giteaAPIRepos = "/api/v1/repos/" func giteaRawContent(targetOwner, targetRepo, ref, giteaRoot, giteaAPIToken, resource string) ([]byte, error) { req := fasthttp.AcquireRequest() - req.SetRequestURI(path.Join(giteaRoot, giteaAPIRepos, targetOwner, targetRepo, "raw", resource+"?ref="+url.QueryEscape(ref))) + apiPath := path.Join(giteaRoot, giteaAPIRepos, targetOwner, targetRepo, "raw", resource+"?ref="+url.QueryEscape(ref)) + log.Debug().Msgf("giteaRawContent: trying path %s", apiPath) + req.SetRequestURI(apiPath) req.Header.Set(fasthttp.HeaderAuthorization, giteaAPIToken) res := fasthttp.AcquireResponse() @@ -37,14 +39,18 @@ func giteaGetRepoBranchTimestamp(giteaRoot, repoOwner, repoName, branchName, git client := getFastHTTPClient(5 * time.Second) req := fasthttp.AcquireRequest() - req.SetRequestURI(path.Join(giteaRoot, giteaAPIRepos, repoOwner, repoName, "branches", branchName)) + apiPath := path.Join(giteaRoot, giteaAPIRepos, repoOwner, repoName, "branches", branchName) + log.Debug().Msgf("giteaGetRepoBranchTimestamp: trying path %s", apiPath) + req.SetRequestURI(apiPath) req.Header.Set(fasthttp.HeaderAuthorization, giteaAPIToken) res := fasthttp.AcquireResponse() if err := client.Do(req, res); err != nil { + log.Err(err) return time.Time{}, err } if res.StatusCode() != fasthttp.StatusOK { + log.Error().Msgf("unexpected status code '%d'", res.StatusCode()) return time.Time{}, fmt.Errorf("unexpected status code '%d'", res.StatusCode()) } return time.Parse(time.RFC3339, fastjson.GetString(res.Body(), "commit", "timestamp")) @@ -54,15 +60,18 @@ func giteaGetRepoDefaultBranch(giteaRoot, repoOwner, repoName, giteaAPIToken str client := getFastHTTPClient(5 * time.Second) req := fasthttp.AcquireRequest() - req.SetRequestURI(path.Join(giteaRoot, giteaAPIRepos, repoOwner, repoName)) - log.Debug().Msgf("trying repo %s/%s", repoOwner, repoName) + apiPath := path.Join(giteaRoot, giteaAPIRepos, repoOwner, repoName) + log.Debug().Msgf("trying path %s", apiPath) + req.SetRequestURI(apiPath) req.Header.Set(fasthttp.HeaderAuthorization, giteaAPIToken) res := fasthttp.AcquireResponse() if err := client.Do(req, res); err != nil { + log.Err(err) return "", err } if res.StatusCode() != fasthttp.StatusOK { + log.Error().Msgf("unexpected status code '%d'", res.StatusCode()) return "", fmt.Errorf("unexpected status code '%d'", res.StatusCode()) } return fastjson.GetString(res.Body(), "default_branch"), nil