mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 02:11:01 +00:00
Gitea driver: ignore GetOrg error if we get a valid user. (#2967)
`[POST] /api/repos?forge_remote_id=12345` ```json {"level":"error","error":"GetOrgByName","time":"2023-12-19T01:03:36Z","caller":"/woodpecker/src/github.com/woodpecker-ci/woodpecker/server/api/repo.go:143","message":"Could not fetch organization from forge."} ``` because `https://codeberg.org/api/v1/orgs/6543` returns an error. `https://codeberg.org/api/v1/users/6543` do not. close #2714
This commit is contained in:
parent
257a76c5ea
commit
1ca549190b
1 changed files with 6 additions and 5 deletions
|
@ -21,6 +21,7 @@ package gitea
|
|||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -548,11 +549,8 @@ func (c *Gitea) Org(ctx context.Context, u *model.User, owner string) (*model.Or
|
|||
return nil, err
|
||||
}
|
||||
|
||||
org, _, err := client.GetOrg(owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if org != nil {
|
||||
org, _, orgErr := client.GetOrg(owner)
|
||||
if orgErr == nil && org != nil {
|
||||
return &model.Org{
|
||||
Name: org.UserName,
|
||||
Private: gitea.VisibleType(org.Visibility) != gitea.VisibleTypePublic,
|
||||
|
@ -561,6 +559,9 @@ func (c *Gitea) Org(ctx context.Context, u *model.User, owner string) (*model.Or
|
|||
|
||||
user, _, err := client.GetUserInfo(owner)
|
||||
if err != nil {
|
||||
if orgErr != nil {
|
||||
err = errors.Join(orgErr, err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &model.Org{
|
||||
|
|
Loading…
Reference in a new issue