diff --git a/CHANGELOG.md b/CHANGELOG.md index 9283c209f..c51b9f2c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [v1.74.3](https://github.com/k1LoW/tbls/compare/v1.74.2...v1.74.3) - 2024-05-06 +### Other Changes +- Use `ghfs` for AnalyzeGithubContent by @kromiii in https://github.com/k1LoW/tbls/pull/581 + ## [v1.74.2](https://github.com/k1LoW/tbls/compare/v1.74.1...v1.74.2) - 2024-05-02 ### Fix bug 🐛 - Support the case where name in index_info is NULL. by @k1LoW in https://github.com/k1LoW/tbls/pull/579 diff --git a/cmd/root.go b/cmd/root.go index a4c24b310..7e7a626c1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -37,10 +37,10 @@ import ( "github.com/spf13/cobra" ) -// adjust is a flag on whethre to adjust the notation width of the table +// adjust is a flag on whether to adjust the notation width of the table var adjust bool -// force is a flag on whether to force genarate +// force is a flag on whether to force generate var force bool // sort is a flag on whether to sort tables, columns, and more diff --git a/config/config.go b/config/config.go index a632f723f..3de9102b9 100644 --- a/config/config.go +++ b/config/config.go @@ -862,7 +862,7 @@ func detectCardinality(s *schema.Schema) error { // parent if r.ParentCardinality == schema.UnknownCardinality { - // whether the child colums are nullable or not. + // whether the child columns are nullable or not. nullable := true for _, c := range r.Columns { if !c.Nullable { diff --git a/datasource/datasource.go b/datasource/datasource.go index 0b161f612..7866da407 100644 --- a/datasource/datasource.go +++ b/datasource/datasource.go @@ -2,7 +2,6 @@ package datasource import ( "bytes" - "context" "encoding/json" "io" "net/http" @@ -11,7 +10,7 @@ import ( "strings" "time" - "github.com/google/go-github/v58/github" + "github.com/k1LoW/ghfs" "github.com/k1LoW/go-github-client/v58/factory" "github.com/k1LoW/tbls/config" "github.com/k1LoW/tbls/drivers" @@ -167,25 +166,22 @@ func AnalyzeGitHubContent(dsn config.DSN) (*schema.Schema, error) { if len(splitted) != 3 { return nil, errors.Errorf("invalid dsn: %s", dsn) } - ctx := context.Background() s := &schema.Schema{} options := []factory.Option{factory.OwnerRepo(splitted[0] + "/" + splitted[1])} c, err := factory.NewGithubClient(options...) if err != nil { return nil, errors.WithStack(err) } - f, _, _, err := c.Repositories.GetContents(ctx, splitted[0], splitted[1], splitted[2], &github.RepositoryContentGetOptions{}) + o := ghfs.Client(c) + fsys, err := ghfs.New(splitted[0], splitted[1], o) if err != nil { return nil, errors.WithStack(err) } - if f == nil { - return nil, errors.Errorf("invalid dsn: %s", dsn) - } - cc, err := f.GetContent() + b, err := fsys.ReadFile(splitted[2]) if err != nil { return nil, errors.WithStack(err) } - dec := json.NewDecoder(strings.NewReader(cc)) + dec := json.NewDecoder(bytes.NewReader(b)) if err := dec.Decode(s); err != nil { return s, errors.WithStack(err) } diff --git a/go.mod b/go.mod index 9ff7e3d7d..89fc3ebdd 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/k1LoW/tbls -go 1.22.1 +go 1.22.2 require ( cloud.google.com/go/bigquery v1.61.0 @@ -109,6 +109,7 @@ require ( github.com/josharian/txtarfs v0.0.0-20210615234325-77aca6df5bca // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/k1LoW/fontdir v0.1.1 // indirect + github.com/k1LoW/ghfs v1.3.1 // indirect github.com/klauspost/compress v1.17.4 // indirect github.com/klauspost/cpuid/v2 v2.2.6 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/go.sum b/go.sum index 581fc99da..4f9392e06 100644 --- a/go.sum +++ b/go.sum @@ -247,6 +247,8 @@ github.com/k1LoW/ffff v0.2.0/go.mod h1:XuWQte6DCVCGKkvfeOFHTihuYWusf7dU+kp9jot7F github.com/k1LoW/fontdir v0.1.0/go.mod h1:9Zbr3T3BXZ5ypr1BM/JwzZN4bqBvl1+JnSTTg1c+zHg= github.com/k1LoW/fontdir v0.1.1 h1:MGpv3LbkbpdVsEX6BCtsYeoQUZSzvb1RF1c/cfumUUw= github.com/k1LoW/fontdir v0.1.1/go.mod h1:9Zbr3T3BXZ5ypr1BM/JwzZN4bqBvl1+JnSTTg1c+zHg= +github.com/k1LoW/ghfs v1.3.1 h1:xq/VenCDhSUDf1IsL0LBfWIn3QTCOOd8+pE0SNZF6wM= +github.com/k1LoW/ghfs v1.3.1/go.mod h1:IaAooDKpTdx/I0lSethYNMowo0rs0h/+btPPHdZlnE4= github.com/k1LoW/go-github-client/v58 v58.0.12 h1:rIK+H2cSpK0ptOxNq0jITGu3ffRjLTe5ITCz1jik5c0= github.com/k1LoW/go-github-client/v58 v58.0.12/go.mod h1:HFCYt6OBzCfusKY4aVYi4E3T4pbDDNdHQuWOL0pHkdI= github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= diff --git a/schema/schema.go b/schema/schema.go index e1af37448..e435881b1 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -223,7 +223,7 @@ func (s *Schema) FindTableByName(name string) (*Table, error) { return nil, errors.Errorf("not found table '%s'", name) } -// FindRelation find relation by columns and parent colums +// FindRelation find relation by columns and parent columns func (s *Schema) FindRelation(cs, pcs []*Column) (*Relation, error) { L: for _, r := range s.Relations { diff --git a/version/version.go b/version/version.go index 8d0f738f9..f543550ce 100644 --- a/version/version.go +++ b/version/version.go @@ -4,4 +4,4 @@ package version const Name string = "tbls" // Version for this -var Version = "1.74.2" +var Version = "1.74.3"