From b5107564382963c2fe66edbfb47ad0787b7a861b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 3 Apr 2023 13:49:33 +0800 Subject: [PATCH] If gitea version is not detected, just fall back to last supported one and print warning (#538) close #531 Reviewed-on: https://gitea.com/gitea/tea/pulls/538 Reviewed-by: John Olheiser Reviewed-by: Lunny Xiao --- go.mod | 2 +- go.sum | 4 ++-- modules/config/login.go | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 748dda1..d519255 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( code.gitea.io/gitea-vet v0.2.1 - code.gitea.io/sdk/gitea v0.15.1-0.20220927025037-8f846bdb9bbe + code.gitea.io/sdk/gitea v0.15.1-0.20230402213053-7511c6d3cd04 gitea.com/noerw/unidiff-comments v0.0.0-20220822113322-50f4daa0e35c github.com/AlecAivazis/survey/v2 v2.3.6 github.com/adrg/xdg v0.4.0 diff --git a/go.sum b/go.sum index ef756ee..c8ae445 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.gitea.io/gitea-vet v0.2.1 h1:b30by7+3SkmiftK0RjuXqFvZg2q4p68uoPGuxhzBN0s= code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE= -code.gitea.io/sdk/gitea v0.15.1-0.20220927025037-8f846bdb9bbe h1:3mI5Ea4NmdFIu4yhENz5YT3FsVGntP47ErcZlb3nPPE= -code.gitea.io/sdk/gitea v0.15.1-0.20220927025037-8f846bdb9bbe/go.mod h1:aRmrQC3CAHdJAU1LQt0C9zqzqI8tUB/5oQtNE746aYE= +code.gitea.io/sdk/gitea v0.15.1-0.20230402213053-7511c6d3cd04 h1:xbZdMnh7SZDgLplAKbmYEA9sZsvTesarfpRHtroagMo= +code.gitea.io/sdk/gitea v0.15.1-0.20230402213053-7511c6d3cd04/go.mod h1:ndkDk99BnfiUCCYEUhpNzi0lpmApXlwRFqClBlOlEBg= gitea.com/noerw/unidiff-comments v0.0.0-20220822113322-50f4daa0e35c h1:8fTkq2UaVkLHZCF+iB4wTxINmVAToe2geZGayk9LMbA= gitea.com/noerw/unidiff-comments v0.0.0-20220822113322-50f4daa0e35c/go.mod h1:Fc8iyPm4NINRWujeIk2bTfcbGc4ZYY29/oMAAGcr4qI= github.com/AlecAivazis/survey/v2 v2.3.6 h1:NvTuVHISgTHEHeBFqt6BHOe4Ny/NwGZr7w+F8S9ziyw= diff --git a/modules/config/login.go b/modules/config/login.go index 31bf2bd..0e7c58a 100644 --- a/modules/config/login.go +++ b/modules/config/login.go @@ -12,6 +12,7 @@ import ( "net/http" "net/http/cookiejar" "net/url" + "os" "strings" "code.gitea.io/sdk/gitea" @@ -207,7 +208,11 @@ func (l *Login) Client(options ...gitea.ClientOption) *gitea.Client { client, err := gitea.NewClient(l.URL, options...) if err != nil { - log.Fatal(err) + var versionError *gitea.ErrUnknownVersion + if !errors.As(err, &versionError) { + log.Fatal(err) + } + fmt.Fprintf(os.Stderr, "WARNING: could not detect gitea version: %s\nINFO: set gitea version: to last supported one\n", versionError) } return client }