Skip to content

Commit

Permalink
Merge branch 'main' of github.com:k1LoW/tbls
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed May 16, 2024
2 parents c6d15ac + 648faf5 commit 00587eb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 5 additions & 9 deletions datasource/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package datasource

import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
Expand All @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ package version
const Name string = "tbls"

// Version for this
var Version = "1.74.2"
var Version = "1.74.3"

0 comments on commit 00587eb

Please sign in to comment.