Skip to content

Commit 00587eb

Browse files
committed
Merge branch 'main' of github.com:k1LoW/tbls
2 parents c6d15ac + 648faf5 commit 00587eb

File tree

8 files changed

+18
-15
lines changed

8 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [v1.74.3](https://github.com/k1LoW/tbls/compare/v1.74.2...v1.74.3) - 2024-05-06
4+
### Other Changes
5+
- Use `ghfs` for AnalyzeGithubContent by @kromiii in https://github.com/k1LoW/tbls/pull/581
6+
37
## [v1.74.2](https://github.com/k1LoW/tbls/compare/v1.74.1...v1.74.2) - 2024-05-02
48
### Fix bug 🐛
59
- Support the case where name in index_info is NULL. by @k1LoW in https://github.com/k1LoW/tbls/pull/579

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ import (
3737
"github.com/spf13/cobra"
3838
)
3939

40-
// adjust is a flag on whethre to adjust the notation width of the table
40+
// adjust is a flag on whether to adjust the notation width of the table
4141
var adjust bool
4242

43-
// force is a flag on whether to force genarate
43+
// force is a flag on whether to force generate
4444
var force bool
4545

4646
// sort is a flag on whether to sort tables, columns, and more

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ func detectCardinality(s *schema.Schema) error {
862862

863863
// parent
864864
if r.ParentCardinality == schema.UnknownCardinality {
865-
// whether the child colums are nullable or not.
865+
// whether the child columns are nullable or not.
866866
nullable := true
867867
for _, c := range r.Columns {
868868
if !c.Nullable {

datasource/datasource.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package datasource
22

33
import (
44
"bytes"
5-
"context"
65
"encoding/json"
76
"io"
87
"net/http"
@@ -11,7 +10,7 @@ import (
1110
"strings"
1211
"time"
1312

14-
"github.com/google/go-github/v58/github"
13+
"github.com/k1LoW/ghfs"
1514
"github.com/k1LoW/go-github-client/v58/factory"
1615
"github.com/k1LoW/tbls/config"
1716
"github.com/k1LoW/tbls/drivers"
@@ -167,25 +166,22 @@ func AnalyzeGitHubContent(dsn config.DSN) (*schema.Schema, error) {
167166
if len(splitted) != 3 {
168167
return nil, errors.Errorf("invalid dsn: %s", dsn)
169168
}
170-
ctx := context.Background()
171169
s := &schema.Schema{}
172170
options := []factory.Option{factory.OwnerRepo(splitted[0] + "/" + splitted[1])}
173171
c, err := factory.NewGithubClient(options...)
174172
if err != nil {
175173
return nil, errors.WithStack(err)
176174
}
177-
f, _, _, err := c.Repositories.GetContents(ctx, splitted[0], splitted[1], splitted[2], &github.RepositoryContentGetOptions{})
175+
o := ghfs.Client(c)
176+
fsys, err := ghfs.New(splitted[0], splitted[1], o)
178177
if err != nil {
179178
return nil, errors.WithStack(err)
180179
}
181-
if f == nil {
182-
return nil, errors.Errorf("invalid dsn: %s", dsn)
183-
}
184-
cc, err := f.GetContent()
180+
b, err := fsys.ReadFile(splitted[2])
185181
if err != nil {
186182
return nil, errors.WithStack(err)
187183
}
188-
dec := json.NewDecoder(strings.NewReader(cc))
184+
dec := json.NewDecoder(bytes.NewReader(b))
189185
if err := dec.Decode(s); err != nil {
190186
return s, errors.WithStack(err)
191187
}

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/k1LoW/tbls
22

3-
go 1.22.1
3+
go 1.22.2
44

55
require (
66
cloud.google.com/go/bigquery v1.61.0
@@ -109,6 +109,7 @@ require (
109109
github.com/josharian/txtarfs v0.0.0-20210615234325-77aca6df5bca // indirect
110110
github.com/json-iterator/go v1.1.12 // indirect
111111
github.com/k1LoW/fontdir v0.1.1 // indirect
112+
github.com/k1LoW/ghfs v1.3.1 // indirect
112113
github.com/klauspost/compress v1.17.4 // indirect
113114
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
114115
github.com/mattn/go-colorable v0.1.13 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ github.com/k1LoW/ffff v0.2.0/go.mod h1:XuWQte6DCVCGKkvfeOFHTihuYWusf7dU+kp9jot7F
247247
github.com/k1LoW/fontdir v0.1.0/go.mod h1:9Zbr3T3BXZ5ypr1BM/JwzZN4bqBvl1+JnSTTg1c+zHg=
248248
github.com/k1LoW/fontdir v0.1.1 h1:MGpv3LbkbpdVsEX6BCtsYeoQUZSzvb1RF1c/cfumUUw=
249249
github.com/k1LoW/fontdir v0.1.1/go.mod h1:9Zbr3T3BXZ5ypr1BM/JwzZN4bqBvl1+JnSTTg1c+zHg=
250+
github.com/k1LoW/ghfs v1.3.1 h1:xq/VenCDhSUDf1IsL0LBfWIn3QTCOOd8+pE0SNZF6wM=
251+
github.com/k1LoW/ghfs v1.3.1/go.mod h1:IaAooDKpTdx/I0lSethYNMowo0rs0h/+btPPHdZlnE4=
250252
github.com/k1LoW/go-github-client/v58 v58.0.12 h1:rIK+H2cSpK0ptOxNq0jITGu3ffRjLTe5ITCz1jik5c0=
251253
github.com/k1LoW/go-github-client/v58 v58.0.12/go.mod h1:HFCYt6OBzCfusKY4aVYi4E3T4pbDDNdHQuWOL0pHkdI=
252254
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=

schema/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (s *Schema) FindTableByName(name string) (*Table, error) {
223223
return nil, errors.Errorf("not found table '%s'", name)
224224
}
225225

226-
// FindRelation find relation by columns and parent colums
226+
// FindRelation find relation by columns and parent columns
227227
func (s *Schema) FindRelation(cs, pcs []*Column) (*Relation, error) {
228228
L:
229229
for _, r := range s.Relations {

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ package version
44
const Name string = "tbls"
55

66
// Version for this
7-
var Version = "1.74.2"
7+
var Version = "1.74.3"

0 commit comments

Comments
 (0)