fix: duplicate processing in ordered formatters #24
|
@ -57,7 +57,7 @@ func TestDependencyCycle(t *testing.T) {
|
|||
})
|
||||
|
||||
_, err := cmd(t, "--config-file", configPath, "--tree-root", tempDir)
|
||||
as.ErrorContains(err, "formatter cycle detected a -> b -> c")
|
||||
as.ErrorContains(err, "formatter cycle detected")
|
||||
}
|
||||
|
||||
func TestSpecifyingFormatters(t *testing.T) {
|
||||
|
|
|
@ -122,6 +122,10 @@ func (f *Formatter) SetChild(formatter *Formatter) {
|
|||
// Wants is used to test if a Formatter wants path based on it's configured Includes and Excludes patterns.
|
||||
// Returns true if the Formatter should be applied to path, false otherwise.
|
||||
func (f *Formatter) Wants(path string) bool {
|
||||
if f.parent != nil {
|
||||
// we don't accept this path directly, our parent will forward it
|
||||
return false
|
||||
}
|
||||
match := !PathMatches(path, f.excludes) && PathMatches(path, f.includes)
|
||||
if match {
|
||||
f.log.Debugf("match: %v", path)
|
||||
|
|
|
@ -3,9 +3,10 @@ package walk
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
)
|
||||
|
||||
type gitWalker struct {
|
||||
|
@ -18,14 +19,12 @@ func (g *gitWalker) Root() string {
|
|||
}
|
||||
|
||||
func (g *gitWalker) Walk(ctx context.Context, fn filepath.WalkFunc) error {
|
||||
|
||||
idx, err := g.repo.Storer.Index()
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: failed to open index", err)
|
||||
}
|
||||
|
||||
for _, entry := range idx.Entries {
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
|
@ -38,7 +37,6 @@ func (g *gitWalker) Walk(ctx context.Context, fn filepath.WalkFunc) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
nativeBuildInputs =
|
||||
# we need some formatters available for the tests
|
||||
(import ./formatters.nix pkgs);
|
||||
import ./formatters.nix pkgs;
|
||||
|
||||
preCheck = ''
|
||||
XDG_CACHE_HOME=$(mktemp -d)
|
||||
|
|
Reference in New Issue
Block a user