if gitea version is not detected, just fall back to last supported one and print warning #538

Merged
6543 merged 4 commits from 6543/tea:option_to_ignore_gitea-version into main 2023-04-03 05:49:34 +00:00
Owner

close #531

close #531
6543 added 2 commits 2023-04-02 21:49:04 +00:00
6543 added the
kind/bug
kind/dependency
labels 2023-04-02 21:49:18 +00:00
6543 added this to the v0.10.0 milestone 2023-04-02 21:49:23 +00:00
6543 reviewed 2023-04-02 21:49:55 +00:00
@ -211,0 +210,4 @@
if !errors.Is(err, gitea.ErrUnknownVersion{}) {
log.Fatal(err)
}
fmt.Println("WARNING: could not detect gitea version!\nINFO: set gitea version: to last supported one")
Author
Owner

hmm we should print to stderr

hmm we should print to stderr
6543 marked this conversation as resolved
6543 added 1 commit 2023-04-02 21:50:41 +00:00
stderr
All checks were successful
check-and-test / check-and-test (pull_request) Successful in 31s
a48bb6f43a
jolheiser reviewed 2023-04-02 21:51:44 +00:00
@ -208,3 +209,3 @@
client, err := gitea.NewClient(l.URL, options...)
if err != nil {
log.Fatal(err)
if !errors.Is(err, gitea.ErrUnknownVersion{}) {
Owner

You'll want to use errors.As here.

You'll want to use `errors.As` here.
6543 marked this conversation as resolved
6543 added 1 commit 2023-04-02 21:57:21 +00:00
error as
All checks were successful
check-and-test / check-and-test (pull_request) Successful in 30s
6aa3c2aca3
6543 reviewed 2023-04-02 21:57:39 +00:00
@ -208,3 +209,3 @@
client, err := gitea.NewClient(l.URL, options...)
if err != nil {
log.Fatal(err)
var versionError *gitea.ErrUnknownVersion
Author
Owner

only if we wana have the actual error back ... done

only if we wana have the actual error back ... done
6543 marked this conversation as resolved
6543 reviewed 2023-04-02 21:58:02 +00:00
Author
Owner

You'll want to use errors.As here.

only if we wana have the actual error back ... done

PS: could not replay on the code-comment, looks like a bug, is it known?

> You'll want to use `errors.As` here. only if we wana have the actual error back ... done PS: could not replay on the code-comment, looks like a bug, is it known?
Owner

You'll want to use errors.As here.

only if we wana have the actual error back ... done

PS: could not replay on the code-comment, looks like a bug, is it known?

Since it's not a sentinel error, we actually do need errors.As
https://go.dev/play/p/t0jJd1D6bzZ

The review reply button bug is known, and should be fixed by https://github.com/go-gitea/gitea/pull/23846 (the commit right after current gitea.com 😅)

> > You'll want to use `errors.As` here. > > only if we wana have the actual error back ... done > > PS: could not replay on the code-comment, looks like a bug, is it known? Since it's not a sentinel error, we actually do need `errors.As` https://go.dev/play/p/t0jJd1D6bzZ The review reply button bug is known, and should be fixed by https://github.com/go-gitea/gitea/pull/23846 (the commit right after current gitea.com 😅)
jolheiser approved these changes 2023-04-02 22:36:54 +00:00
Author
Owner

...tual error back ... done

PS: could not replay on the code-comment, looks like a bug, is it known?

Since it's not a sentinel error, we actually do need errors.As
https://go.dev/play/p/t0jJd1D6bzZ

uh missed that in the sdk review ... you need to implement a interface and it works:

https://pkg.go.dev/errors#Is
-> func (m MyError) Is(target error) bool { return target == fs.ErrExist }

https://go.dev/play/p/le6FbO90IGU

> > ...tual error back ... done > > > > PS: could not replay on the code-comment, looks like a bug, is it known? > > Since it's not a sentinel error, we actually do need `errors.As` > https://go.dev/play/p/t0jJd1D6bzZ uh missed that in the sdk review ... you need to implement a interface and it works: https://pkg.go.dev/errors#Is -> `func (m MyError) Is(target error) bool { return target == fs.ErrExist }` https://go.dev/play/p/le6FbO90IGU
Owner

True, I had chosen not to at the time because it seemed more explicit, but I suppose most people just care about true/false, not necessarily if it matches a specific pattern.

I can make a follow up PR there.

True, I had chosen not to at the time because it seemed more explicit, but I suppose most people just care about true/false, not necessarily if it matches a specific pattern. I can make a follow up PR there.
lunny approved these changes 2023-04-03 03:43:50 +00:00
6543 merged commit b510756438 into main 2023-04-03 05:49:34 +00:00
6543 deleted branch option_to_ignore_gitea-version 2023-04-03 05:49:34 +00:00
Sign in to join this conversation.
No description provided.