From 844f3fd6e0711778a7a233d76f9b07cde0bf8393 Mon Sep 17 00:00:00 2001 From: Brian McGee Date: Sat, 12 Oct 2024 11:48:12 +0100 Subject: [PATCH] feat: simplify git walking Replaces the use of `go-git` with a simple `git ls-file` for traversing the git index. Signed-off-by: Brian McGee --- cmd/root_test.go | 191 +++++++++++++----------- config/config.go | 4 +- go.mod | 20 +-- go.sum | 112 +------------- nix/packages/treefmt/default.nix | 10 +- nix/packages/treefmt/gomod2nix.toml | 60 +------- walk/filesystem.go | 22 ++- walk/filetree.go | 62 -------- walk/filetree_test.go | 31 ---- walk/git.go | 222 +++++++++------------------- walk/git_test.go | 40 ++--- walk/type_enum.go | 30 ++-- walk/walk.go | 13 +- 13 files changed, 246 insertions(+), 571 deletions(-) delete mode 100644 walk/filetree.go delete mode 100644 walk/filetree_test.go diff --git a/cmd/root_test.go b/cmd/root_test.go index b037f4d..3571589 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -12,6 +12,8 @@ import ( "testing" "time" + "github.com/numtide/treefmt/walk" + "github.com/numtide/treefmt/cmd" "github.com/numtide/treefmt/config" @@ -25,11 +27,6 @@ import ( "github.com/numtide/treefmt/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" - "github.com/stretchr/testify/require" ) @@ -733,7 +730,7 @@ func TestBustCacheOnFormatterChange(t *testing.T) { }) } -func TestGitWorktree(t *testing.T) { +func TestGit(t *testing.T) { as := require.New(t) tempDir := test.TempExamples(t) @@ -751,20 +748,6 @@ func TestGitWorktree(t *testing.T) { test.WriteConfig(t, configPath, cfg) - // init a git repo - repo, err := git.Init( - filesystem.NewStorage( - osfs.New(path.Join(tempDir, ".git")), - cache.NewObjectLRUDefault(), - ), - osfs.New(tempDir), - ) - as.NoError(err, "failed to init git repository") - - // get worktree - wt, err := repo.Worktree() - as.NoError(err, "failed to get git worktree") - run := func(traversed int32, matched int32, formatted int32, changed int32) { _, statz, err := treefmt(t, "-c", "--config-file", configPath, "--tree-root", tempDir) as.NoError(err) @@ -777,30 +760,43 @@ func TestGitWorktree(t *testing.T) { }) } - // run before adding anything to the worktree + // init a git repo + gitCmd := exec.Command("git", "init") + gitCmd.Dir = tempDir + as.NoError(gitCmd.Run(), "failed to init git repository") + + // run before adding anything to the index run(0, 0, 0, 0) - // add everything to the worktree - as.NoError(wt.AddGlob(".")) - as.NoError(err) + // add everything to the index + gitCmd = exec.Command("git", "add", ".") + gitCmd.Dir = tempDir + as.NoError(gitCmd.Run(), "failed to add everything to the index") + run(32, 32, 32, 0) - // remove python directory from the worktree - as.NoError(wt.RemoveGlob("python/*")) + // remove python directory from the index + gitCmd = exec.Command("git", "rm", "--cached", "python/*") + gitCmd.Dir = tempDir + as.NoError(gitCmd.Run(), "failed to remove python directory from the index") + run(29, 29, 29, 0) // remove nixpkgs.toml from the filesystem but leave it in the index as.NoError(os.Remove(filepath.Join(tempDir, "nixpkgs.toml"))) run(28, 28, 28, 0) - // walk with filesystem instead of git - // we should traverse more files since we will look in the .git folder + // walk with filesystem instead of with git + // the .git folder contains 49 additional files + // when added to the 31 we started with (32 minus nixpkgs.toml which we removed from the filesystem), we should + // traverse 80 files. _, statz, err := treefmt(t, "-c", "--config-file", configPath, "--tree-root", tempDir, "--walk", "filesystem") as.NoError(err) assertStats(t, as, statz, map[stats.Type]int32{ - stats.Traversed: 60, - stats.Matched: 60, + stats.Traversed: 80, + stats.Matched: 80, + stats.Formatted: 80, stats.Changed: 0, }) @@ -1109,65 +1105,86 @@ func TestDeterministicOrderingInPipeline(t *testing.T) { func TestRunInSubdir(t *testing.T) { as := require.New(t) - // capture current cwd, so we can replace it after the test is finished - cwd, err := os.Getwd() - as.NoError(err) - - t.Cleanup(func() { - // return to the previous working directory - as.NoError(os.Chdir(cwd)) - }) - - tempDir := test.TempExamples(t) - configPath := filepath.Join(tempDir, "/treefmt.toml") - - // Also test that formatters are resolved relative to the treefmt root - echoPath, err := exec.LookPath("echo") - as.NoError(err) - echoRel := path.Join(tempDir, "echo") - err = os.Symlink(echoPath, echoRel) - as.NoError(err) - - // change working directory to sub directory - as.NoError(os.Chdir(filepath.Join(tempDir, "elm"))) + // Run the same test for each walk type + for _, walkType := range walk.TypeValues() { + t.Run(walkType.String(), func(t *testing.T) { + // capture current cwd, so we can replace it after the test is finished + cwd, err := os.Getwd() + as.NoError(err) + + t.Cleanup(func() { + // return to the previous working directory + as.NoError(os.Chdir(cwd)) + }) + + tempDir := test.TempExamples(t) + configPath := filepath.Join(tempDir, "/treefmt.toml") + + // set the walk type via environment variable + t.Setenv("TREEFMT_WALK_TYPE", walkType.String()) + + // if we are testing git walking, init a git repo before continuing + if walkType == walk.Git { + // init a git repo + gitCmd := exec.Command("git", "init") + gitCmd.Dir = tempDir + as.NoError(gitCmd.Run(), "failed to init git repository") + + // add everything to the index + gitCmd = exec.Command("git", "add", ".") + gitCmd.Dir = tempDir + as.NoError(gitCmd.Run(), "failed to add everything to the index") + } - // basic config - cfg := &config.Config{ - FormatterConfigs: map[string]*config.Formatter{ - "echo": { - Command: "./echo", - Includes: []string{"*"}, - }, - }, + // test that formatters are resolved relative to the treefmt root + echoPath, err := exec.LookPath("echo") + as.NoError(err) + echoRel := path.Join(tempDir, "echo") + err = os.Symlink(echoPath, echoRel) + as.NoError(err) + + // change working directory to subdirectory + as.NoError(os.Chdir(filepath.Join(tempDir, "elm"))) + + // basic config + cfg := &config.Config{ + FormatterConfigs: map[string]*config.Formatter{ + "echo": { + Command: "./echo", + Includes: []string{"*"}, + }, + }, + } + test.WriteConfig(t, configPath, cfg) + + // without any path args, should reformat the whole tree + _, statz, err := treefmt(t) + as.NoError(err) + + assertStats(t, as, statz, map[stats.Type]int32{ + stats.Traversed: 32, + stats.Matched: 32, + stats.Formatted: 32, + stats.Changed: 0, + }) + + // specify some explicit paths, relative to the tree root + // this should not work, as we're in a subdirectory + _, _, err = treefmt(t, "-c", "elm/elm.json", "haskell/Nested/Foo.hs") + as.ErrorContains(err, "path elm/elm.json not found") + + // specify some explicit paths, relative to the current directory + _, statz, err = treefmt(t, "-c", "elm.json", "../haskell/Nested/Foo.hs") + as.NoError(err) + + assertStats(t, as, statz, map[stats.Type]int32{ + stats.Traversed: 2, + stats.Matched: 2, + stats.Formatted: 2, + stats.Changed: 0, + }) + }) } - test.WriteConfig(t, configPath, cfg) - - // without any path args, should reformat the whole tree - _, statz, err := treefmt(t) - as.NoError(err) - - assertStats(t, as, statz, map[stats.Type]int32{ - stats.Traversed: 32, - stats.Matched: 32, - stats.Formatted: 32, - stats.Changed: 0, - }) - - // specify some explicit paths, relative to the tree root - // this should not work, as we're in a subdirectory - _, _, err = treefmt(t, "-c", "elm/elm.json", "haskell/Nested/Foo.hs") - as.ErrorContains(err, "path elm/elm.json not found") - - // specify some explicit paths, relative to the current directory - _, statz, err = treefmt(t, "-c", "elm.json", "../haskell/Nested/Foo.hs") - as.NoError(err) - - assertStats(t, as, statz, map[stats.Type]int32{ - stats.Traversed: 2, - stats.Matched: 2, - stats.Formatted: 2, - stats.Changed: 0, - }) } func treefmt(t *testing.T, args ...string) ([]byte, *stats.Stats, error) { diff --git a/config/config.go b/config/config.go index 801a5d0..7d723ca 100644 --- a/config/config.go +++ b/config/config.go @@ -122,8 +122,8 @@ func SetFlags(fs *pflag.FlagSet) { ) fs.String( "walk", "auto", - "The method used to traverse the files within the tree root. Currently supports 'auto', 'git' or "+ - "'filesystem'. (env $TREEFMT_WALK)", + "The method used to traverse the files within the tree root. Currently supports "+ + ". (env $TREEFMT_WALK)", ) fs.StringP( "working-dir", "C", ".", diff --git a/go.mod b/go.mod index b5b018f..7612b49 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,6 @@ require ( github.com/BurntSushi/toml v1.4.0 github.com/adrg/xdg v0.5.0 github.com/charmbracelet/log v0.4.0 - github.com/go-git/go-billy/v5 v5.5.1-0.20241008101053-371e232676ac - github.com/go-git/go-git/v5 v5.12.1-0.20240930111449-d1843220b6ab github.com/gobwas/glob v0.2.3 github.com/otiai10/copy v1.14.0 github.com/spf13/cobra v1.8.1 @@ -21,23 +19,13 @@ require ( ) require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/charmbracelet/lipgloss v0.10.0 // indirect - github.com/cloudflare/circl v1.3.8 // indirect - github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/emirpasic/gods v1.18.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -47,28 +35,22 @@ require ( github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.2 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect - github.com/skeema/knownhosts v1.3.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect - golang.org/x/net v0.29.0 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/term v0.24.0 // indirect golang.org/x/text v0.18.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ccc1c0b..9cff630 100644 --- a/go.sum +++ b/go.sum @@ -1,76 +1,37 @@ -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= -github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= -github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY= github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s= github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI= -github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= -github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elazarl/goproxy v0.0.0-20240618083138-03be62527ccb h1:2SoxRauy2IqekRMggrQk3yNI5X6omSnk6ugVbFywwXs= -github.com/elazarl/goproxy v0.0.0-20240618083138-03be62527ccb/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= -github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= -github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= -github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.1-0.20240930170605-5f263c979534 h1:ReIiJ3+RmLoagnYcjfgxfxAaIG+zkzttS56LvUsnKN8= -github.com/go-git/go-billy/v5 v5.5.1-0.20240930170605-5f263c979534/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= -github.com/go-git/go-billy/v5 v5.5.1-0.20241008101053-371e232676ac h1:DZTX1zgrLjV7Z52zg+rndiqEItTJaGt7dnQCD70fzfw= -github.com/go-git/go-billy/v5 v5.5.1-0.20241008101053-371e232676ac/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.12.1-0.20240930111449-d1843220b6ab h1:90RNld1ZF+pwfooOog4MslWouh9+IxERrqKxpHbJAdg= -github.com/go-git/go-git/v5 v5.12.1-0.20240930111449-d1843220b6ab/go.mod h1:bN6A1YeroE4hsEk6jE8Tk507NxnKZNJLVABgVuChAFg= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= -github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -94,18 +55,12 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= -github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= -github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -120,11 +75,6 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= -github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= -github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -141,9 +91,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -155,86 +103,28 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= -github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/nix/packages/treefmt/default.nix b/nix/packages/treefmt/default.nix index 943ba82..22dd615 100644 --- a/nix/packages/treefmt/default.nix +++ b/nix/packages/treefmt/default.nix @@ -47,12 +47,20 @@ in ]; nativeBuildInputs = + [pkgs.git] + ++ # we need some formatters available for the tests import ./formatters.nix pkgs; preCheck = '' + HOME=$(mktemp -d) XDG_CACHE_HOME=$(mktemp -d) - export XDG_CACHE_HOME + + export HOME XDG_CACHE_HOME + + # setup a git user for committing during tests + git config --global user.email "" + git config --global user.name "Treefmt Test" ''; meta = with lib; { diff --git a/nix/packages/treefmt/gomod2nix.toml b/nix/packages/treefmt/gomod2nix.toml index 78a05e8..9f6a2cf 100644 --- a/nix/packages/treefmt/gomod2nix.toml +++ b/nix/packages/treefmt/gomod2nix.toml @@ -1,18 +1,9 @@ schema = 3 [mod] - [mod."dario.cat/mergo"] - version = "v1.0.0" - hash = "sha256-jlpc8dDj+DmiOU4gEawBu8poJJj9My0s9Mvuk9oS8ww=" [mod."github.com/BurntSushi/toml"] version = "v1.4.0" hash = "sha256-3cr8hfVA4th/AfveHDxigmj8Eiiae0ZBnxAgy+7RYO4=" - [mod."github.com/Microsoft/go-winio"] - version = "v0.6.2" - hash = "sha256-tVNWDUMILZbJvarcl/E7tpSnkn7urqgSHa2Eaka5vSU=" - [mod."github.com/ProtonMail/go-crypto"] - version = "v1.0.0" - hash = "sha256-Gflazvyv+457FpUTtPafJ+SdolYSalpsU0tragTxNi8=" [mod."github.com/adrg/xdg"] version = "v0.5.0" hash = "sha256-hYxtRzeFzT+4zbslWSZWmUJf+OBDmCiwL0D/0Ry8Z2I=" @@ -25,51 +16,24 @@ schema = 3 [mod."github.com/charmbracelet/log"] version = "v0.4.0" hash = "sha256-VQerB44vC646n3fe3haJ3DHa9L5+GRhCfDfm1p3QnZk=" - [mod."github.com/cloudflare/circl"] - version = "v1.3.8" - hash = "sha256-6FbUbOjD8UDb2DIUzVCtI6S+Ja7Dk1pQLc0j0SWZaCk=" - [mod."github.com/cyphar/filepath-securejoin"] - version = "v0.2.5" - hash = "sha256-Hb9fRUHnMJJwy7XuHRG2l0YiTKh/5jUz2YJVdYScIfE=" [mod."github.com/davecgh/go-spew"] version = "v1.1.2-0.20180830191138-d8f796af33cc" hash = "sha256-fV9oI51xjHdOmEx6+dlq7Ku2Ag+m/bmbzPo6A4Y74qc=" - [mod."github.com/emirpasic/gods"] - version = "v1.18.1" - hash = "sha256-hGDKddjLj+5dn2woHtXKUdd49/3xdsqnhx7VEdCu1m4=" [mod."github.com/fsnotify/fsnotify"] version = "v1.7.0" hash = "sha256-MdT2rQyQHspPJcx6n9ozkLbsktIOJutOqDuKpNAtoZY=" - [mod."github.com/go-git/gcfg"] - version = "v1.5.1-0.20230307220236-3a3c6141e376" - hash = "sha256-f4k0gSYuo0/q3WOoTxl2eFaj7WZpdz29ih6CKc8Ude8=" - [mod."github.com/go-git/go-billy/v5"] - version = "v5.5.1-0.20241008101053-371e232676ac" - hash = "sha256-Hw+odNozpiixXqmsbahihdV+TBxpusm6/hDLngf7kUg=" - [mod."github.com/go-git/go-git/v5"] - version = "v5.12.1-0.20240930111449-d1843220b6ab" - hash = "sha256-JdLfdFmmQNhkRN/T2/VWqUee9KvSuf+oKTxn2/mPMzs=" [mod."github.com/go-logfmt/logfmt"] version = "v0.6.0" hash = "sha256-RtIG2qARd5sT10WQ7F3LR8YJhS8exs+KiuUiVf75bWg=" [mod."github.com/gobwas/glob"] version = "v0.2.3" hash = "sha256-hYHMUdwxVkMOjSKjR7UWO0D0juHdI4wL8JEy5plu/Jc=" - [mod."github.com/golang/groupcache"] - version = "v0.0.0-20210331224755-41bb18bfe9da" - hash = "sha256-7Gs7CS9gEYZkbu5P4hqPGBpeGZWC64VDwraSKFF+VR0=" [mod."github.com/hashicorp/hcl"] version = "v1.0.0" hash = "sha256-xsRCmYyBfglMxeWUvTZqkaRLSW+V2FvNodEDjTGg1WA=" [mod."github.com/inconshreveable/mousetrap"] version = "v1.1.0" hash = "sha256-XWlYH0c8IcxAwQTnIi6WYqq44nOKUylSWxWO/vi+8pE=" - [mod."github.com/jbenet/go-context"] - version = "v0.0.0-20150711004518-d14ea06fba99" - hash = "sha256-VANNCWNNpARH/ILQV9sCQsBWgyL2iFT+4AHZREpxIWE=" - [mod."github.com/kevinburke/ssh_config"] - version = "v1.2.0" - hash = "sha256-Ta7ZOmyX8gG5tzWbY2oES70EJPfI90U7CIJS9EAce0s=" [mod."github.com/lucasb-eyer/go-colorful"] version = "v1.2.0" hash = "sha256-Gg9dDJFCTaHrKHRR1SrJgZ8fWieJkybljybkI9x0gyE=" @@ -100,9 +64,6 @@ schema = 3 [mod."github.com/pelletier/go-toml/v2"] version = "v2.2.2" hash = "sha256-ukxk1Cfm6cQW18g/aa19tLcUu5BnF7VmfAvrDHAOl6A=" - [mod."github.com/pjbgf/sha1cd"] - version = "v0.3.0" - hash = "sha256-kX9BdLh2dxtGNaDvc24NORO+C0AZ7JzbrXrtecCdB7w=" [mod."github.com/pmezard/go-difflib"] version = "v1.0.1-0.20181226105442-5d4384ee4fb2" hash = "sha256-XA4Oj1gdmdV/F/+8kMI+DBxKPthZ768hbKsO3d9Gx90=" @@ -115,12 +76,6 @@ schema = 3 [mod."github.com/sagikazarmark/slog-shim"] version = "v0.1.0" hash = "sha256-F92BQXXmn3mCwu3mBaGh+joTRItQDSDhsjU6SofkYdA=" - [mod."github.com/sergi/go-diff"] - version = "v1.3.2-0.20230802210424-5b0b94c5c0d3" - hash = "sha256-UcLU83CPMbSoKI8RLvLJ7nvGaE2xRSL1RjoHCVkMzUM=" - [mod."github.com/skeema/knownhosts"] - version = "v1.3.0" - hash = "sha256-piR5IdfqxK9nxyErJ+IRDLnkaeNQwX93ztTFZyPm5MQ=" [mod."github.com/sourcegraph/conc"] version = "v0.3.0" hash = "sha256-mIdMs9MLAOBKf3/0quf1iI3v8uNWydy7ae5MFa+F2Ko=" @@ -151,9 +106,6 @@ schema = 3 [mod."github.com/vmihailenco/tagparser/v2"] version = "v2.0.0" hash = "sha256-M9QyaKhSmmYwsJk7gkjtqu9PuiqZHSmTkous8VWkWY0=" - [mod."github.com/xanzy/ssh-agent"] - version = "v0.3.3" - hash = "sha256-l3pGB6IdzcPA/HLk93sSN6NM2pKPy+bVOoacR5RC2+c=" [mod."go.etcd.io/bbolt"] version = "v1.3.11" hash = "sha256-SVWYZtE9TBgAo8xJSmo9DtSwuNa056N3zGvPLDJgiA8=" @@ -163,15 +115,9 @@ schema = 3 [mod."go.uber.org/multierr"] version = "v1.9.0" hash = "sha256-tlDRooh/V4HDhZohsUrxot/Y6uVInVBtRWCZbj/tPds=" - [mod."golang.org/x/crypto"] - version = "v0.27.0" - hash = "sha256-8HP4+gr4DbXI22GhdgZmCWr1ijtI9HNLsTcE0kltY9o=" [mod."golang.org/x/exp"] version = "v0.0.0-20240719175910-8a7402abbf56" hash = "sha256-mHEPy0vbd/pFwq5ZAEKaehCeYVQLEFDGnXAoVgkCLPo=" - [mod."golang.org/x/net"] - version = "v0.29.0" - hash = "sha256-dH9Rdf5T04KJ4B5WvIZh12ogMbADWiWgIt77nvPTk2k=" [mod."golang.org/x/sync"] version = "v0.8.0" hash = "sha256-usvF0z7gq1vsX58p4orX+8WHlv52pdXgaueXlwj2Wss=" @@ -184,12 +130,12 @@ schema = 3 [mod."golang.org/x/text"] version = "v0.18.0" hash = "sha256-aNvJW4gQs+MTfdz6DZqyyHQS2GJ9W8L8qKPVODPn4+k=" + [mod."gopkg.in/check.v1"] + version = "v1.0.0-20201130134442-10cb98267c6c" + hash = "sha256-VlIpM2r/OD+kkyItn6vW35dyc0rtkJufA93rjFyzncs=" [mod."gopkg.in/ini.v1"] version = "v1.67.0" hash = "sha256-V10ahGNGT+NLRdKUyRg1dos5RxLBXBk1xutcnquc/+4=" - [mod."gopkg.in/warnings.v0"] - version = "v0.1.2" - hash = "sha256-ATVL9yEmgYbkJ1DkltDGRn/auGAjqGOfjQyBYyUo8s8=" [mod."gopkg.in/yaml.v3"] version = "v3.0.1" hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU=" diff --git a/walk/filesystem.go b/walk/filesystem.go index dc536e5..0980b2c 100644 --- a/walk/filesystem.go +++ b/walk/filesystem.go @@ -77,7 +77,7 @@ func (f *FilesystemReader) process() error { }) } -// Read populates the provided files array with as many files are available until the provided context is cancelled. +// Read populates the provided files array with as many files as are available until the provided context is cancelled. // You must ensure to pass a context with a timeout otherwise this will block until files is full. func (f *FilesystemReader) Read(ctx context.Context, files []*File) (n int, err error) { // ensure we record how many files we traversed @@ -85,32 +85,30 @@ func (f *FilesystemReader) Read(ctx context.Context, files []*File) (n int, err f.stats.Add(stats.Traversed, int32(n)) }() - idx := 0 - LOOP: - // fill the files array up to it's length - for idx < len(files) { + // keep filling files up to it's length + for n < len(files) { select { // exit early if the context was cancelled case <-ctx.Done(): - return idx, ctx.Err() + return n, ctx.Err() - // read the next file from the files channel + // read the next file from the channel case file, ok := <-f.filesCh: if !ok { - // channel was closed + // channel was closed, exit the loop err = io.EOF break LOOP } - // set the next file entry - files[idx] = file - idx++ + // add to the file array and increment n + files[n] = file + n++ } } - return idx, err + return n, err } // Close waits for all filesystem processing to complete. diff --git a/walk/filetree.go b/walk/filetree.go deleted file mode 100644 index 02139db..0000000 --- a/walk/filetree.go +++ /dev/null @@ -1,62 +0,0 @@ -package walk - -import ( - "path/filepath" - "strings" - - "github.com/go-git/go-git/v5/plumbing/format/index" -) - -// filetree represents a hierarchical file structure with directories and files. -type filetree struct { - name string - entries map[string]*filetree -} - -// add inserts a file path into the filetree structure, creating necessary parent directories if they do not exist. -func (n *filetree) add(path []string) { - if len(path) == 0 { - return - } else if n.entries == nil { - n.entries = make(map[string]*filetree) - } - - name := path[0] - child, ok := n.entries[name] - if !ok { - child = &filetree{name: name} - n.entries[name] = child - } - child.add(path[1:]) -} - -// addPath splits the given path by the filepath separator and inserts it into the filetree structure. -func (n *filetree) addPath(path string) { - n.add(strings.Split(path, string(filepath.Separator))) -} - -// has returns true if the specified path exists in the filetree, false otherwise. -func (n *filetree) has(path []string) bool { - if len(path) == 0 { - return true - } else if len(n.entries) == 0 { - return false - } - child, ok := n.entries[path[0]] - if !ok { - return false - } - return child.has(path[1:]) -} - -// hasPath splits the given path by the filepath separator and checks if it exists in the filetree. -func (n *filetree) hasPath(path string) bool { - return n.has(strings.Split(path, string(filepath.Separator))) -} - -// readIndex traverses the index entries and adds each file path to the filetree structure. -func (n *filetree) readIndex(idx *index.Index) { - for _, entry := range idx.Entries { - n.addPath(entry.Name) - } -} diff --git a/walk/filetree_test.go b/walk/filetree_test.go deleted file mode 100644 index 6ef68d3..0000000 --- a/walk/filetree_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package walk - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestFileTree(t *testing.T) { - as := require.New(t) - - node := &filetree{name: ""} - node.addPath("foo/bar/baz") - node.addPath("fizz/buzz") - node.addPath("hello/world") - node.addPath("foo/bar/fizz") - node.addPath("foo/fizz/baz") - - as.True(node.hasPath("foo")) - as.True(node.hasPath("foo/bar")) - as.True(node.hasPath("foo/bar/baz")) - as.True(node.hasPath("fizz")) - as.True(node.hasPath("fizz/buzz")) - as.True(node.hasPath("hello")) - as.True(node.hasPath("hello/world")) - as.True(node.hasPath("foo/bar/fizz")) - as.True(node.hasPath("foo/fizz/baz")) - - as.False(node.hasPath("fo")) - as.False(node.hasPath("world")) -} diff --git a/walk/git.go b/walk/git.go index 91d13d7..edf8887 100644 --- a/walk/git.go +++ b/walk/git.go @@ -1,169 +1,98 @@ package walk import ( + "bufio" "context" "fmt" "io" - "io/fs" "os" + "os/exec" "path/filepath" - "runtime" "strings" "github.com/charmbracelet/log" - "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing/filemode" "github.com/numtide/treefmt/stats" "golang.org/x/sync/errgroup" ) type GitReader struct { - root string - path string - stats *stats.Stats - batchSize int + root string + path string - log *log.Logger - repo *git.Repository + log *log.Logger + stats *stats.Stats - filesCh chan *File - - eg *errgroup.Group + eg *errgroup.Group + scanner *bufio.Scanner } -func (g *GitReader) process() error { +func (g *GitReader) Read(ctx context.Context, files []*File) (n int, err error) { + // ensure we record how many files we traversed defer func() { - close(g.filesCh) + g.stats.Add(stats.Traversed, int32(n)) }() - gitIndex, err := g.repo.Storer.Index() - if err != nil { - return fmt.Errorf("failed to open git index: %w", err) - } - - // if we need to walk a path that is not the root of the repository, we will read the directory structure of the - // git index into memory for faster lookups - var idxCache *filetree - - path := filepath.Clean(filepath.Join(g.root, g.path)) - if !strings.HasPrefix(path, g.root) { - return fmt.Errorf("path '%s' is outside of the root '%s'", path, g.root) - } - - switch path { - - case g.root: - - // we can just iterate the index entries - for _, entry := range gitIndex.Entries { + if g.scanner == nil { + // create a pipe to capture the command output + r, w := io.Pipe() - // we only want regular files, not directories or symlinks - if entry.Mode == filemode.Dir || entry.Mode == filemode.Symlink { - continue - } - - // stat the file - path := filepath.Join(g.root, entry.Name) + // create a command which will execute from the specified sub path within root + cmd := exec.Command("git", "ls-files") + cmd.Dir = filepath.Join(g.root, g.path) + cmd.Stdout = w - info, err := os.Lstat(path) - if os.IsNotExist(err) { - // the underlying file might have been removed without the change being staged yet - g.log.Warnf("Path %s is in the index but appears to have been removed from the filesystem", path) - continue - } else if err != nil { - return fmt.Errorf("failed to stat %s: %w", path, err) - } - - // determine a relative path - relPath, err := filepath.Rel(g.root, path) - if err != nil { - return fmt.Errorf("failed to determine a relative path for %s: %w", path, err) - } - - file := File{ - Path: path, - RelPath: relPath, - Info: info, - } - - g.stats.Add(stats.Traversed, 1) - g.filesCh <- &file - } - - default: - - // read the git index into memory if it hasn't already - if idxCache == nil { - idxCache = &filetree{name: ""} - idxCache.readIndex(gitIndex) - } - - // git index entries are relative to the repository root, so we need to determine a relative path for the - // one we are currently processing before checking if it exists within the git index - relPath, err := filepath.Rel(g.root, path) - if err != nil { - return fmt.Errorf("failed to find root relative path for %v: %w", path, err) - } - - if !idxCache.hasPath(relPath) { - log.Debugf("path %s not found in git index, skipping", relPath) - return nil - } - - err = filepath.Walk(path, func(path string, info fs.FileInfo, _ error) error { - // skip directories - if info.IsDir() { - return nil - } - - // determine a path relative to g.root before checking presence in the git index - relPath, err := filepath.Rel(g.root, path) - if err != nil { - return fmt.Errorf("failed to determine a relative path for %s: %w", path, err) - } - - if !idxCache.hasPath(relPath) { - log.Debugf("path %v not found in git index, skipping", relPath) - return nil - } - - file := File{ - Path: path, - RelPath: relPath, - Info: info, - } - - g.stats.Add(stats.Traversed, 1) - g.filesCh <- &file - return nil + // execute the command in the background + g.eg.Go(func() error { + return w.CloseWithError(cmd.Run()) }) - if err != nil { - return fmt.Errorf("failed to walk %s: %w", path, err) - } - } - - return nil -} -func (g *GitReader) Read(ctx context.Context, files []*File) (n int, err error) { - idx := 0 + // create a new scanner for reading the output + g.scanner = bufio.NewScanner(r) + } LOOP: - for idx < len(files) { + + for n < len(files) { select { + + // exit early if the context was cancelled case <-ctx.Done(): - return 0, ctx.Err() - case file, ok := <-g.filesCh: - if !ok { + return n, ctx.Err() + + default: + // read the next file + if g.scanner.Scan() { + path := filepath.Join(g.root, g.path, g.scanner.Text()) + + g.log.Debugf("processing file: %s", path) + + info, err := os.Stat(path) + if os.IsNotExist(err) { + // the underlying file might have been removed + g.log.Warnf( + "Path %s is in the worktree but appears to have been removed from the filesystem", path, + ) + continue + } else if err != nil { + return n, fmt.Errorf("failed to stat %s: %w", path, err) + } + + files[n] = &File{ + Path: path, + RelPath: filepath.Join(g.path, g.scanner.Text()), + Info: info, + } + n++ + + } else { + // nothing more to read err = io.EOF break LOOP } - files[idx] = file - idx++ } } - return idx, err + return n, err } func (g *GitReader) Close() error { @@ -174,27 +103,22 @@ func NewGitReader( root string, path string, statz *stats.Stats, - batchSize int, ) (*GitReader, error) { - repo, err := git.PlainOpen(root) - if err != nil { - return nil, fmt.Errorf("failed to open git repository: %w", err) + // check if the root is a git repository + cmd := exec.Command("git", "rev-parse", "--is-inside-work-tree") + cmd.Dir = root + + if out, err := cmd.Output(); err != nil { + return nil, fmt.Errorf("failed to check if %s is a git repository: %w", root, err) + } else if strings.Trim(string(out), "\n") != "true" { + return nil, fmt.Errorf("%s is not a git repository", root) } - eg := &errgroup.Group{} - - r := &GitReader{ - root: root, - path: path, - stats: statz, - batchSize: batchSize, - log: log.WithPrefix("walk[git]"), - repo: repo, - filesCh: make(chan *File, batchSize*runtime.NumCPU()), - eg: eg, - } - - eg.Go(r.process) - - return r, nil + return &GitReader{ + root: root, + path: path, + stats: statz, + eg: &errgroup.Group{}, + log: log.WithPrefix("walk[git]"), + }, nil } diff --git a/walk/git_test.go b/walk/git_test.go index 2b2abbc..c7f8ff8 100644 --- a/walk/git_test.go +++ b/walk/git_test.go @@ -4,14 +4,10 @@ import ( "context" "errors" "io" - "path" + "os/exec" "testing" "time" - "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" "github.com/numtide/treefmt/stats" "github.com/numtide/treefmt/test" "github.com/numtide/treefmt/walk" @@ -24,23 +20,29 @@ func TestGitReader(t *testing.T) { tempDir := test.TempExamples(t) // init a git repo - repo, err := git.Init( - filesystem.NewStorage( - osfs.New(path.Join(tempDir, ".git")), - cache.NewObjectLRUDefault(), - ), - osfs.New(tempDir), - ) - as.NoError(err, "failed to init git repository") - - // get worktree and add everything to it - wt, err := repo.Worktree() - as.NoError(err, "failed to get git worktree") - as.NoError(wt.AddGlob(".")) + cmd := exec.Command("git", "init") + cmd.Dir = tempDir + as.NoError(cmd.Run(), "failed to init git repository") + // read empty worktree statz := stats.New() + reader, err := walk.NewGitReader(tempDir, "", &statz) + as.NoError(err) + + files := make([]*walk.File, 8) + ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) + n, err := reader.Read(ctx, files) + + cancel() + as.Equal(0, n) + as.ErrorIs(err, io.EOF) + + // add everything to the git index + cmd = exec.Command("git", "add", ".") + cmd.Dir = tempDir + as.NoError(cmd.Run(), "failed to add everything to the index") - reader, err := walk.NewGitReader(tempDir, "", &statz, 1024) + reader, err = walk.NewGitReader(tempDir, "", &statz) as.NoError(err) count := 0 diff --git a/walk/type_enum.go b/walk/type_enum.go index ba377ab..4550804 100644 --- a/walk/type_enum.go +++ b/walk/type_enum.go @@ -7,11 +7,11 @@ import ( "strings" ) -const _TypeName = "autogitfilesystemstdin" +const _TypeName = "autostdinfilesystemgit" -var _TypeIndex = [...]uint8{0, 4, 7, 17, 22} +var _TypeIndex = [...]uint8{0, 4, 9, 19, 22} -const _TypeLowerName = "autogitfilesystemstdin" +const _TypeLowerName = "autostdinfilesystemgit" func (i Type) String() string { if i < 0 || i >= Type(len(_TypeIndex)-1) { @@ -25,29 +25,29 @@ func (i Type) String() string { func _TypeNoOp() { var x [1]struct{} _ = x[Auto-(0)] - _ = x[Git-(1)] + _ = x[Stdin-(1)] _ = x[Filesystem-(2)] - _ = x[Stdin-(3)] + _ = x[Git-(3)] } -var _TypeValues = []Type{Auto, Git, Filesystem, Stdin} +var _TypeValues = []Type{Auto, Stdin, Filesystem, Git} var _TypeNameToValueMap = map[string]Type{ _TypeName[0:4]: Auto, _TypeLowerName[0:4]: Auto, - _TypeName[4:7]: Git, - _TypeLowerName[4:7]: Git, - _TypeName[7:17]: Filesystem, - _TypeLowerName[7:17]: Filesystem, - _TypeName[17:22]: Stdin, - _TypeLowerName[17:22]: Stdin, + _TypeName[4:9]: Stdin, + _TypeLowerName[4:9]: Stdin, + _TypeName[9:19]: Filesystem, + _TypeLowerName[9:19]: Filesystem, + _TypeName[19:22]: Git, + _TypeLowerName[19:22]: Git, } var _TypeNames = []string{ _TypeName[0:4], - _TypeName[4:7], - _TypeName[7:17], - _TypeName[17:22], + _TypeName[4:9], + _TypeName[9:19], + _TypeName[19:22], } // TypeString retrieves an enum value from the enum constants string name. diff --git a/walk/walk.go b/walk/walk.go index 7805a43..ffdfe7a 100644 --- a/walk/walk.go +++ b/walk/walk.go @@ -20,9 +20,9 @@ type Type int const ( Auto Type = iota - Git - Filesystem Stdin + Filesystem + Git BatchSize = 1024 ) @@ -159,12 +159,13 @@ func NewReader( reader, err = NewReader(Filesystem, root, path, db, statz) } return reader, err - case Git: - reader, err = NewGitReader(root, path, statz, BatchSize) - case Filesystem: - reader = NewFilesystemReader(root, path, statz, BatchSize) case Stdin: return nil, fmt.Errorf("stdin walk type is not supported") + case Filesystem: + reader = NewFilesystemReader(root, path, statz, BatchSize) + case Git: + reader, err = NewGitReader(root, path, statz) + default: return nil, fmt.Errorf("unknown walk type: %v", walkType) }