Add gitea/forgejo driver check, to handle ErrUnknownVersion error (#3243)

close  #3240
This commit is contained in:
6543 2024-01-21 22:07:37 +01:00 committed by GitHub
parent b24970f358
commit 8ca51971be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -586,7 +586,8 @@ func (c *Gitea) newClientToken(ctx context.Context, token string) (*gitea.Client
}
}
client, err := gitea.NewClient(c.url, gitea.SetToken(token), gitea.SetHTTPClient(httpClient), gitea.SetContext(ctx))
if err != nil && strings.Contains(err.Error(), "Malformed version") {
if err != nil &&
(errors.Is(err, &gitea.ErrUnknownVersion{}) || strings.Contains(err.Error(), "Malformed version")) {
// we guess it's a dev gitea version
log.Error().Err(err).Msgf("could not detect gitea version, assume dev version %s", giteaDevVersion)
client, err = gitea.NewClient(c.url, gitea.SetGiteaVersion(giteaDevVersion), gitea.SetToken(token), gitea.SetHTTPClient(httpClient), gitea.SetContext(ctx))