1
0
mirror of https://gitea.com/gitea/tea.git synced 2024-11-03 04:27:21 -05:00

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 <john+gitea@jolheiser.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
6543 2023-04-03 13:49:33 +08:00
parent 3640bbac5e
commit b510756438
3 changed files with 9 additions and 4 deletions

2
go.mod
View File

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

4
go.sum
View File

@ -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=

View File

@ -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
}