1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

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))