chore: remove internal directory
Signed-off-by: Brian McGee <brian@bmcgee.ie>
This commit is contained in:
parent
0fbae06f19
commit
b68ba86996
4
internal/cache/cache.go → cache/cache.go
vendored
4
internal/cache/cache.go → cache/cache.go
vendored
|
@ -9,9 +9,9 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/walk"
|
||||
"git.numtide.com/numtide/treefmt/format"
|
||||
"git.numtide.com/numtide/treefmt/walk"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/format"
|
||||
"github.com/charmbracelet/log"
|
||||
|
||||
"github.com/adrg/xdg"
|
|
@ -1,7 +1,7 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"git.numtide.com/numtide/treefmt/internal/walk"
|
||||
"git.numtide.com/numtide/treefmt/walk"
|
||||
"github.com/alecthomas/kong"
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
|
@ -11,12 +11,10 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/walk"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/config"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/cache"
|
||||
"git.numtide.com/numtide/treefmt/internal/format"
|
||||
"git.numtide.com/numtide/treefmt/cache"
|
||||
"git.numtide.com/numtide/treefmt/config"
|
||||
format2 "git.numtide.com/numtide/treefmt/format"
|
||||
"git.numtide.com/numtide/treefmt/walk"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
@ -47,7 +45,7 @@ func (f *Format) Run() error {
|
|||
return fmt.Errorf("%w: failed to read config file", err)
|
||||
}
|
||||
|
||||
globalExcludes, err := format.CompileGlobs(cfg.Global.Excludes)
|
||||
globalExcludes, err := format2.CompileGlobs(cfg.Global.Excludes)
|
||||
|
||||
// create optional formatter filter set
|
||||
formatterSet := make(map[string]bool)
|
||||
|
@ -68,7 +66,7 @@ func (f *Format) Run() error {
|
|||
}
|
||||
}
|
||||
|
||||
formatters := make(map[string]*format.Formatter)
|
||||
formatters := make(map[string]*format2.Formatter)
|
||||
|
||||
// detect broken dependencies
|
||||
for name, formatterCfg := range cfg.Formatters {
|
||||
|
@ -115,8 +113,8 @@ func (f *Format) Run() error {
|
|||
continue
|
||||
}
|
||||
|
||||
formatter, err := format.NewFormatter(name, formatterCfg, globalExcludes)
|
||||
if errors.Is(err, format.ErrCommandNotFound) && Cli.AllowMissingFormatter {
|
||||
formatter, err := format2.NewFormatter(name, formatterCfg, globalExcludes)
|
||||
if errors.Is(err, format2.ErrCommandNotFound) && Cli.AllowMissingFormatter {
|
||||
l.Debugf("formatter not found: %v", name)
|
||||
continue
|
||||
} else if err != nil {
|
||||
|
@ -147,7 +145,7 @@ func (f *Format) Run() error {
|
|||
//
|
||||
completedCh := make(chan string, 1024)
|
||||
|
||||
ctx = format.SetCompletedChannel(ctx, completedCh)
|
||||
ctx = format2.SetCompletedChannel(ctx, completedCh)
|
||||
|
||||
//
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
|
@ -8,15 +8,15 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/config"
|
||||
config2 "git.numtide.com/numtide/treefmt/config"
|
||||
"git.numtide.com/numtide/treefmt/format"
|
||||
"git.numtide.com/numtide/treefmt/test"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/test"
|
||||
"github.com/go-git/go-billy/v5/osfs"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/cache"
|
||||
"github.com/go-git/go-git/v5/storage/filesystem"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/format"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -26,8 +26,8 @@ func TestAllowMissingFormatter(t *testing.T) {
|
|||
tempDir := t.TempDir()
|
||||
configPath := tempDir + "/treefmt.toml"
|
||||
|
||||
test.WriteConfig(t, configPath, config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
test.WriteConfig(t, configPath, config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"foo-fmt": {
|
||||
Command: "foo-fmt",
|
||||
},
|
||||
|
@ -47,8 +47,8 @@ func TestDependencyCycle(t *testing.T) {
|
|||
tempDir := t.TempDir()
|
||||
configPath := tempDir + "/treefmt.toml"
|
||||
|
||||
test.WriteConfig(t, configPath, config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
test.WriteConfig(t, configPath, config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"a": {Command: "echo", Before: "b"},
|
||||
"b": {Command: "echo", Before: "c"},
|
||||
"c": {Command: "echo", Before: "a"},
|
||||
|
@ -68,8 +68,8 @@ func TestSpecifyingFormatters(t *testing.T) {
|
|||
tempDir := test.TempExamples(t)
|
||||
configPath := tempDir + "/treefmt.toml"
|
||||
|
||||
test.WriteConfig(t, configPath, config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
test.WriteConfig(t, configPath, config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"elm": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*.elm"},
|
||||
|
@ -117,8 +117,8 @@ func TestIncludesAndExcludes(t *testing.T) {
|
|||
configPath := tempDir + "/echo.toml"
|
||||
|
||||
// test without any excludes
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"echo": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*"},
|
||||
|
@ -189,8 +189,8 @@ func TestCache(t *testing.T) {
|
|||
configPath := tempDir + "/echo.toml"
|
||||
|
||||
// test without any excludes
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"echo": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*"},
|
||||
|
@ -224,8 +224,8 @@ func TestChangeWorkingDirectory(t *testing.T) {
|
|||
configPath := tempDir + "/treefmt.toml"
|
||||
|
||||
// test without any excludes
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"echo": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*"},
|
||||
|
@ -249,8 +249,8 @@ func TestFailOnChange(t *testing.T) {
|
|||
configPath := tempDir + "/echo.toml"
|
||||
|
||||
// test without any excludes
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"echo": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*"},
|
||||
|
@ -285,8 +285,8 @@ func TestBustCacheOnFormatterChange(t *testing.T) {
|
|||
as.NoError(os.Setenv("PATH", binPath+":"+os.Getenv("PATH")))
|
||||
|
||||
// start with 2 formatters
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"python": {
|
||||
Command: "black",
|
||||
Includes: []string{"*.py"},
|
||||
|
@ -330,7 +330,7 @@ func TestBustCacheOnFormatterChange(t *testing.T) {
|
|||
as.Contains(string(out), "0 files changed")
|
||||
|
||||
// add go formatter
|
||||
cfg.Formatters["go"] = &config.Formatter{
|
||||
cfg.Formatters["go"] = &config2.Formatter{
|
||||
Command: "gofmt",
|
||||
Options: []string{"-w"},
|
||||
Includes: []string{"*.go"},
|
||||
|
@ -380,8 +380,8 @@ func TestGitWorktree(t *testing.T) {
|
|||
configPath := filepath.Join(tempDir, "/treefmt.toml")
|
||||
|
||||
// basic config
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"echo": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*"},
|
||||
|
@ -435,8 +435,8 @@ func TestOrderingFormatters(t *testing.T) {
|
|||
configPath := path.Join(tempDir, "treefmt.toml")
|
||||
|
||||
// missing child
|
||||
test.WriteConfig(t, configPath, config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
test.WriteConfig(t, configPath, config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"hs-a": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*.hs"},
|
||||
|
@ -449,8 +449,8 @@ func TestOrderingFormatters(t *testing.T) {
|
|||
as.ErrorContains(err, "formatter hs-a is before hs-b but config for hs-b was not found")
|
||||
|
||||
// multiple roots
|
||||
test.WriteConfig(t, configPath, config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
test.WriteConfig(t, configPath, config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"hs-a": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*.hs"},
|
||||
|
@ -501,8 +501,8 @@ func TestPathsArg(t *testing.T) {
|
|||
as.NoError(os.Chdir(tempDir))
|
||||
|
||||
// basic config
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"echo": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*"},
|
||||
|
@ -545,8 +545,8 @@ func TestStdIn(t *testing.T) {
|
|||
as.NoError(os.Chdir(tempDir))
|
||||
|
||||
// basic config
|
||||
cfg := config.Config{
|
||||
Formatters: map[string]*config.Formatter{
|
||||
cfg := config2.Config{
|
||||
Formatters: map[string]*config2.Formatter{
|
||||
"echo": {
|
||||
Command: "echo",
|
||||
Includes: []string{"*"},
|
|
@ -7,7 +7,8 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/test"
|
||||
"git.numtide.com/numtide/treefmt/test"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
|
@ -9,7 +9,7 @@ import (
|
|||
func TestReadConfigFile(t *testing.T) {
|
||||
as := require.New(t)
|
||||
|
||||
cfg, err := ReadFile("../../test/treefmt.toml")
|
||||
cfg, err := ReadFile("../test/treefmt.toml")
|
||||
as.NoError(err, "failed to read config file")
|
||||
|
||||
as.NotNil(cfg)
|
|
@ -7,7 +7,7 @@ import (
|
|||
"os/exec"
|
||||
"time"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/config"
|
||||
"git.numtide.com/numtide/treefmt/config"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/gobwas/glob"
|
2
main.go
2
main.go
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"git.numtide.com/numtide/treefmt/internal/cli"
|
||||
"git.numtide.com/numtide/treefmt/cli"
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"git.numtide.com/numtide/treefmt/internal/config"
|
||||
"git.numtide.com/numtide/treefmt/config"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
cp "github.com/otiai10/copy"
|
||||
|
@ -25,7 +25,7 @@ func WriteConfig(t *testing.T, path string, cfg config.Config) {
|
|||
|
||||
func TempExamples(t *testing.T) string {
|
||||
tempDir := t.TempDir()
|
||||
require.NoError(t, cp.Copy("../../test/examples", tempDir), "failed to copy test data to temp dir")
|
||||
require.NoError(t, cp.Copy("../test/examples", tempDir), "failed to copy test data to temp dir")
|
||||
return tempDir
|
||||
}
|
||||
|
Reference in New Issue
Block a user