Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Fix to map the avatar_url field #366

Merged
merged 2 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ require (
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.6.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/go-github/v42 v42.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
Expand Down Expand Up @@ -68,11 +69,11 @@ require (
github.com/ugorji/go/codec v1.2.6 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,19 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github/v32 v32.1.0 h1:GWkQOdXqviCPx7Q7Fj+KyPoGm4SwHRh8rheoPhd27II=
github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
github.com/google/go-github/v42 v42.0.0 h1:YNT0FwjPrEysRkLIiKuEfSvBPCGKphW5aS5PxwaoLec=
github.com/google/go-github/v42 v42.0.0/go.mod h1:jgg/jvyI0YlDOM1/ps6XYh04HNQ3vKf0CVko62/EhRg=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -506,6 +511,8 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -735,6 +742,7 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/github/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/gitploy-io/gitploy/model/ent"
"github.com/gitploy-io/gitploy/model/extent"
"github.com/gitploy-io/gitploy/pkg/e"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
)

func (g *Github) CreateRemoteDeployment(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*extent.RemoteDeployment, error) {
Expand Down Expand Up @@ -47,7 +47,7 @@ func (g *Github) CreateRemoteDeployment(ctx context.Context, u *ent.User, r *ent
var url string
commit, _, err := g.Client(ctx, u.Token).
Repositories.
GetCommit(ctx, r.Namespace, r.Name, *gd.SHA)
GetCommit(ctx, r.Namespace, r.Name, *gd.SHA, &github.ListOptions{})
if err == nil {
url = *commit.HTMLURL
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/github/deploymentstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gitploy-io/gitploy/model/ent"
"github.com/gitploy-io/gitploy/model/extent"
"github.com/gitploy-io/gitploy/pkg/e"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
)

func (g *Github) CreateRemoteDeploymentStatus(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, ds *extent.RemoteDeploymentStatus) (*extent.RemoteDeploymentStatus, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
graphql "github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)
Expand Down
12 changes: 7 additions & 5 deletions internal/pkg/github/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"

"github.com/gitploy-io/gitploy/model/extent"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
)

func mapGithubUserToUser(u *github.User) *extent.RemoteUser {
Expand Down Expand Up @@ -32,7 +32,7 @@ func mapGithubRepoToRemotePerm(r *github.Repository) *extent.RemoteRepo {
Namespace: namespace,
Name: name,
Description: *r.Description,
Perm: mapGithubPermToRepoPerm(*r.Permissions),
Perm: mapGithubPermToRepoPerm(r.Permissions),
}
}

Expand Down Expand Up @@ -100,13 +100,15 @@ func mapGithubStatusToStatus(s *github.RepoStatus) *extent.Status {
}

status := &extent.Status{
Context: *s.Context,
AvatarURL: "",
State: state,
Context: *s.Context,
State: state,
}
if s.TargetURL != nil {
status.TargetURL = *s.TargetURL
}
if s.AvatarURL != nil {
status.AvatarURL = *s.AvatarURL
}

return status
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/github/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net/http"

"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
graphql "github.com/shurcooL/githubv4"

"github.com/gitploy-io/gitploy/internal/interactor"
Expand Down Expand Up @@ -51,7 +51,7 @@ func (g *Github) CompareCommits(ctx context.Context, u *ent.User, r *ent.Repo, b
// TODO: Support pagination.
res, _, err := g.Client(ctx, u.Token).
Repositories.
CompareCommits(ctx, r.Namespace, r.Name, base, head)
CompareCommits(ctx, r.Namespace, r.Name, base, head, &github.ListOptions{})
if err != nil {
return nil, nil, err
}
Expand All @@ -72,7 +72,7 @@ func (g *Github) CompareCommits(ctx context.Context, u *ent.User, r *ent.Repo, b
func (g *Github) GetCommit(ctx context.Context, u *ent.User, r *ent.Repo, sha string) (*extent.Commit, error) {
cm, res, err := g.Client(ctx, u.Token).
Repositories.
GetCommit(ctx, r.Namespace, r.Name, sha)
GetCommit(ctx, r.Namespace, r.Name, sha, &github.ListOptions{})
// Github returns Unprocessable entity if the commit is not found.
if res.StatusCode == http.StatusNotFound || res.StatusCode == http.StatusUnprocessableEntity {
return nil, e.NewErrorWithMessage(e.ErrorCodeEntityNotFound, "The commit is not found.", err)
Expand Down Expand Up @@ -147,7 +147,7 @@ func (g *Github) ListBranches(ctx context.Context, u *ent.User, r *ent.Repo, opt
func (g *Github) GetBranch(ctx context.Context, u *ent.User, r *ent.Repo, branch string) (*extent.Branch, error) {
b, res, err := g.Client(ctx, u.Token).
Repositories.
GetBranch(ctx, r.Namespace, r.Name, branch)
GetBranch(ctx, r.Namespace, r.Name, branch, false)
if res.StatusCode == http.StatusNotFound {
return nil, e.NewErrorWithMessage(e.ErrorCodeEntityNotFound, "The branch is not found.", err)
} else if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/github/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gitploy-io/gitploy/model/ent"
"github.com/gitploy-io/gitploy/model/extent"
"github.com/gitploy-io/gitploy/pkg/e"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
)

func (g *Github) ListRemoteRepos(ctx context.Context, u *ent.User) ([]*extent.RemoteRepo, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/github/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/gitploy-io/gitploy/model/ent"
"github.com/gitploy-io/gitploy/model/extent"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
)

func (g *Github) GetRateLimit(ctx context.Context, u *ent.User) (*extent.RateLimit, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/github/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/gitploy-io/gitploy/model/extent"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
)

func (g *Github) GetRemoteUserByToken(ctx context.Context, token string) (*extent.RemoteUser, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/hooks/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"
"go.uber.org/zap"

gb "github.com/gitploy-io/gitploy/internal/server/global"
Expand Down
2 changes: 1 addition & 1 deletion internal/server/hooks/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/AlekSi/pointer"
"github.com/gin-gonic/gin"
"github.com/golang/mock/gomock"
"github.com/google/go-github/v32/github"
"github.com/google/go-github/v42/github"

"github.com/gitploy-io/gitploy/internal/server/hooks/mock"
"github.com/gitploy-io/gitploy/model/ent"
Expand Down