Skip to content

Commit

Permalink
Merge pull request #284 from k1LoW/fix-scheme-format
Browse files Browse the repository at this point in the history
Fix dsn url (tbls diff output)
  • Loading branch information
k1LoW authored Feb 1, 2021
2 parents 1ac0a60 + c937f2a commit 491ef05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ func TestMaskedDSN(t *testing.T) {
"pg://localhost:5432/testdb?sslmode=disable",
"pg://localhost:5432/testdb?sslmode=disable",
},
{
"bq://project-id/dataset-id?creds=/path/to/google_application_credentials.json",
"bq://project-id/dataset-id?creds=/path/to/google_application_credentials.json",
},
}

for _, tt := range tests {
Expand Down
25 changes: 12 additions & 13 deletions output/md/md.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"text/template"
Expand Down Expand Up @@ -217,7 +216,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}

Expand All @@ -232,7 +231,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {
if err := md.OutputTable(a, t); err != nil {
return "", errors.WithStack(err)
}
from := path.Join(mdsnA, tName)
from := fmt.Sprintf("%s %s", mdsnA, tName)

b := new(bytes.Buffer)
t2, err := s2.FindTableByName(tName)
Expand All @@ -241,7 +240,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {
return "", errors.WithStack(err)
}
}
to := path.Join(mdsnB, tName)
to := fmt.Sprintf("%s %s", mdsnB, tName)

d := difflib.UnifiedDiff{
A: difflib.SplitLines(a.String()),
Expand All @@ -253,7 +252,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand All @@ -263,13 +262,13 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {
continue
}
a := ""
from := path.Join(mdsnA, tName)
from := fmt.Sprintf("%s %s", mdsnA, tName)

b := new(bytes.Buffer)
if err := md.OutputTable(b, t); err != nil {
return "", errors.WithStack(err)
}
to := path.Join(mdsnB, tName)
to := fmt.Sprintf("%s %s", mdsnB, tName)

d := difflib.UnifiedDiff{
A: difflib.SplitLines(a),
Expand All @@ -281,7 +280,7 @@ func DiffSchemas(s, s2 *schema.Schema, c, c2 *config.Config) (string, error) {

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand Down Expand Up @@ -339,7 +338,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}

Expand All @@ -353,7 +352,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri
if _, err := os.Lstat(filepath.Join(fullPath, fmt.Sprintf("%s.%s", t.Name, c.ER.Format))); err == nil {
er = true
}
to := path.Join(mdsn, t.Name)
to := fmt.Sprintf("%s %s", mdsn, t.Name)

md := New(c, er)

Expand All @@ -379,7 +378,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand All @@ -404,7 +403,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri
from := filepath.Join(docPath, f.Name())

b := ""
to := path.Join(mdsn, filepath.Base(fname[:len(fname)-len(filepath.Ext(fname))]))
to := fmt.Sprintf("%s %s", mdsn, filepath.Base(fname[:len(fname)-len(filepath.Ext(fname))]))

d := difflib.UnifiedDiff{
A: difflib.SplitLines(string(a)),
Expand All @@ -416,7 +415,7 @@ func DiffSchemaAndDocs(docPath string, s *schema.Schema, c *config.Config) (stri

text, _ := difflib.GetUnifiedDiffString(d)
if text != "" {
diff += fmt.Sprintf("diff %s '%s'\n", from, to)
diff += fmt.Sprintf("diff '%s' '%s'\n", from, to)
diff += text
}
}
Expand Down

0 comments on commit 491ef05

Please sign in to comment.