mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-22 22:26:20 +00:00
improvements to github enterprise flow when no primary email
This commit is contained in:
parent
1ff56ef51c
commit
522310ecb8
1 changed files with 4 additions and 9 deletions
|
@ -6,7 +6,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/drone/drone/plugin/remote/github/oauth"
|
"github.com/drone/drone/plugin/remote/github/oauth"
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
@ -37,16 +36,12 @@ func GetUserEmail(client *github.Client) (*github.User, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARNING, HACK
|
|
||||||
// for out-of-date github enterprise editions the primary
|
|
||||||
// and verified fields won't exist.
|
|
||||||
if !strings.HasPrefix(*user.HTMLURL, DefaultURL) && len(emails) != 0 && emails[0].Primary == nil {
|
|
||||||
user.Email = emails[0].Email
|
|
||||||
return user, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// else we should iterate through the list
|
// else we should iterate through the list
|
||||||
for _, email := range emails {
|
for _, email := range emails {
|
||||||
|
if email.Primary == nil { // hack for github enterprise
|
||||||
|
user.Email = email.Email
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
if *email.Primary && *email.Verified {
|
if *email.Primary && *email.Verified {
|
||||||
user.Email = email.Email
|
user.Email = email.Email
|
||||||
return user, nil
|
return user, nil
|
||||||
|
|
Loading…
Reference in a new issue