Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoh86 committed Jul 28, 2024
1 parent 190c176 commit e300db4
Show file tree
Hide file tree
Showing 22 changed files with 65,499 additions and 40,997 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ DATE ?= `date --iso-8601`
generate-clear: gen-clear
.PHONY: generate-clear

gen-clear:
gen-clear: clear-sdl
rm -rf ./**/*_gen.go
.PHONY: gen-clear

clear-sdl:
rm -f ./internal/githubv4/schema.graphql
.PHONY: clear-sdl

get-sdl:
curl -Lo ./internal/githubv4/schema.graphql https://docs.github.com/public/fpt/schema.docs.graphql
.PHONY: get-sdl

generate: gen
.PHONY: generate

gen: gen-clear
gen: gen-clear get-sdl
go generate -x ./...
.PHONY: gen

Expand Down
27 changes: 9 additions & 18 deletions cmd/gogh/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/kyoh86/gogh/v2/view"
"github.com/kyoh86/gogh/v2/view/repotab"
"github.com/spf13/cobra"
"github.com/wacul/ptr"
"golang.org/x/sync/errgroup"
"golang.org/x/term"
)
Expand Down Expand Up @@ -42,11 +41,11 @@ var (
var listOption gogh.RemoteListOption
switch reposFlags.Limit {
case 0:
listOption.Limit = ptr.Int(30)
listOption.Limit = 30
case -1:
listOption.Limit = ptr.Int(0) // no limit
listOption.Limit = 0 // no limit
default:
listOption.Limit = &reposFlags.Limit
listOption.Limit = reposFlags.Limit
}
if reposFlags.Private && reposFlags.Public {
return errors.New("specify only one of `--private` or `--public`")
Expand All @@ -62,10 +61,10 @@ var (
return errors.New("specify only one of `--fork` or `--no-fork`")
}
if reposFlags.Fork {
listOption.IsFork = &reposFlags.Fork // &true
listOption.IsFork = reposFlags.Fork // &true
}
if reposFlags.NotFork {
listOption.IsFork = &reposFlags.Fork // &false
listOption.IsFork = reposFlags.Fork // &false
}
LOOP_CONVERT_RELATION:
for _, r := range reposFlags.Relation {
Expand Down Expand Up @@ -100,18 +99,10 @@ var (
}
defer format.Close()
if reposFlags.Sort != "" {
sort := gogh.RepositoryOrderField(reposFlags.Sort)
if !sort.IsValid() {
return fmt.Errorf("invalid sort %q; %s", reposFlags.Sort, fmt.Sprintf("it can accept %s", quoteEnums(repoSortAccept)))
}
listOption.Sort = sort
listOption.Sort = gogh.RepositoryOrderField(reposFlags.Sort)
}
if reposFlags.Order != "" {
order := gogh.OrderDirection(reposFlags.Order)
if !order.IsValid() {
return fmt.Errorf("invalid order %q; %s", reposFlags.Order, fmt.Sprintf("it can accept %s", quoteEnums(repoOrderAccept)))
}
listOption.Order = order
listOption.Order = gogh.OrderDirection(reposFlags.Order)
}
ctx, cancel := context.WithCancel(cmd.Context())
defer cancel()
Expand Down Expand Up @@ -173,10 +164,10 @@ func quoteEnums(values []string) string {
func init() {
repoFormatAccept = []string{"spec", "url", "json", "table"}
for _, v := range gogh.AllRepositoryOrderField {
repoSortAccept = append(repoSortAccept, v.String())
repoSortAccept = append(repoSortAccept, string(v))
}
for _, v := range gogh.AllOrderDirection {
repoOrderAccept = append(repoOrderAccept, v.String())
repoOrderAccept = append(repoOrderAccept, string(v))
}
for _, v := range gogh.AllRepositoryRelation {
repoRelationAccept = append(repoRelationAccept, v.String())
Expand Down
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/kyoh86/gogh/v2

go 1.21
go 1.22

toolchain go1.22.5

require (
Expand Down Expand Up @@ -52,13 +53,16 @@ require (
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Khan/genqlient v0.7.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/alessio/shellescape v1.4.2 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/alexflint/go-arg v1.4.2 // indirect
github.com/alexflint/go-scalar v1.0.0 // indirect
github.com/anchore/bubbly v0.0.0-20230518153401-87b6af8ccf22 // indirect
github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a // indirect
github.com/anchore/go-macholibre v0.0.0-20220308212642-53e6d0aaf6fb // indirect
Expand Down Expand Up @@ -273,7 +277,7 @@ require (
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/urfave/cli/v2 v2.27.1 // indirect
github.com/vbatts/tar-split v0.11.5 // indirect
github.com/vektah/gqlparser/v2 v2.5.14 // indirect
github.com/vektah/gqlparser/v2 v2.5.16 // indirect
github.com/wagoodman/go-partybus v0.0.0-20230516145632-8ccac152c651 // indirect
github.com/wagoodman/go-progress v0.0.0-20220614130704-4b1c25a33c7c // indirect
github.com/whyrusleeping/cbor-gen v0.1.1-0.20240311221002-68b9f235c302 // indirect
Expand Down
12 changes: 10 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
Expand All @@ -95,8 +97,12 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpH
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0=
github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/alexflint/go-arg v1.4.2 h1:lDWZAXxpAnZUq4qwb86p/3rIJJ2Li81EoMbTMujhVa0=
github.com/alexflint/go-arg v1.4.2/go.mod h1:9iRbDxne7LcR/GSvEr7ma++GLpdIU1zrghf2y2768kM=
github.com/alexflint/go-scalar v1.0.0 h1:NGupf1XV/Xb04wXskDFzS0KWOLH632W/EO4fAFi+A70=
github.com/alexflint/go-scalar v1.0.0/go.mod h1:GpHzbCOZXEKMEcygYQ5n/aa4Aq84zbxjy3MxYW0gjYw=
github.com/anchore/bubbly v0.0.0-20230518153401-87b6af8ccf22 h1:5NFK6VGgqBUOAX2SYyzFYvNdOiYDxzim8jga386FlZY=
github.com/anchore/bubbly v0.0.0-20230518153401-87b6af8ccf22/go.mod h1:Kv+Mm9CdtnV8iem48iEPIwy7/N4Wmk0hpxYNH5gTwKQ=
github.com/anchore/go-logger v0.0.0-20230725134548-c21dafa1ec5a h1:nJ2G8zWKASyVClGVgG7sfM5mwoZlZ2zYpIzN2OhjWkw=
Expand Down Expand Up @@ -805,6 +811,8 @@ github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinC
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
github.com/vektah/gqlparser/v2 v2.5.14 h1:dzLq75BJe03jjQm6n56PdH1oweB8ana42wj7E4jRy70=
github.com/vektah/gqlparser/v2 v2.5.14/go.mod h1:WQQjFc+I1YIzoPvZBhUQX7waZgg3pMLi0r8KymvAE2w=
github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8=
github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
github.com/wacul/ptr v1.0.0 h1:FIKu08Wx0YUIf9MNsfF62OCmBSmz5A1Tk65zWhOIL/I=
github.com/wacul/ptr v1.0.0/go.mod h1:BD0gjsZrCwtoR+yWDB9v2hQ8STlq9tT84qKfa+3txOc=
github.com/wagoodman/go-partybus v0.0.0-20230516145632-8ccac152c651 h1:jIVmlAFIqV3d+DOxazTR9v+zgj8+VYuQBzPgBZvWBHA=
Expand Down
17 changes: 10 additions & 7 deletions internal/github/genuine.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import (
"net/http"
"net/url"

"github.com/Khan/genqlient/graphql"
github "github.com/google/go-github/v35/github"
"github.com/kyoh86/gogh/v2/internal/githubv4"
"golang.org/x/oauth2"
)

type genuineAdaptor struct {
host string
gqlClient graphql.Client
restClient *github.Client
gqlClient *githubv4.Client
host string
}

func (a *genuineAdaptor) GetHost() string {
Expand Down Expand Up @@ -78,7 +79,7 @@ func newGenuineAdaptor(host string, httpClient *http.Client) Adaptor {
return &genuineAdaptor{
host: host,
restClient: github.NewClient(httpClient),
gqlClient: githubv4.NewClient(httpClient, "https://"+DefaultAPIHost+"/graphql"),
gqlClient: graphql.NewClient("https://"+DefaultAPIHost+"/graphql", httpClient),
}
}

Expand All @@ -94,7 +95,7 @@ func newGenuineEnterpriseAdaptor(
return &genuineAdaptor{
host: host,
restClient: restClient,
gqlClient: githubv4.NewClient(httpClient, baseGQLURL),
gqlClient: graphql.NewClient(baseGQLURL, httpClient),
}, nil
}

Expand All @@ -116,8 +117,9 @@ func (a *genuineAdaptor) RepositoryList(
ctx context.Context,
opts *RepositoryListOptions,
) ([]*RepositoryFragment, PageInfoFragment, error) {
repos, err := a.gqlClient.ListRepos(
repos, err := githubv4.ListRepos(
ctx,
a.gqlClient,
opts.Limit,
opts.After,
opts.IsFork,
Expand All @@ -130,9 +132,10 @@ func (a *genuineAdaptor) RepositoryList(
}
ingrepos := make([]*RepositoryFragment, 0, len(repos.Viewer.Repositories.Edges))
for _, edge := range repos.Viewer.Repositories.Edges {
ingrepos = append(ingrepos, edge.Node)
f := edge.Node.RepositoryFragment
ingrepos = append(ingrepos, &f)
}
return ingrepos, repos.Viewer.Repositories.PageInfo, nil
return ingrepos, repos.Viewer.Repositories.PageInfo.PageInfoFragment, nil
}

func (a *genuineAdaptor) RepositoryCreate(
Expand Down
12 changes: 6 additions & 6 deletions internal/github/if.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const (
)

type RepositoryListOptions struct {
Limit *int64
After *string
IsFork *bool
Privacy *RepositoryPrivacy
OrderBy *RepositoryOrder
OwnerAffiliations []*RepositoryAffiliation
OrderBy RepositoryOrder
After string
Privacy RepositoryPrivacy
OwnerAffiliations []RepositoryAffiliation
Limit int
IsFork bool
}

type Adaptor interface {
Expand Down
17 changes: 0 additions & 17 deletions internal/githubv4/.gqlgenc.yml

This file was deleted.

5 changes: 0 additions & 5 deletions internal/githubv4/.graphql.yml

This file was deleted.

Loading

0 comments on commit e300db4

Please sign in to comment.