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)
|
_, 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) {
|
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.
|
// 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.
|
// Returns true if the Formatter should be applied to path, false otherwise.
|
||||||
func (f *Formatter) Wants(path string) bool {
|
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)
|
match := !PathMatches(path, f.excludes) && PathMatches(path, f.includes)
|
||||||
if match {
|
if match {
|
||||||
f.log.Debugf("match: %v", path)
|
f.log.Debugf("match: %v", path)
|
||||||
|
@ -3,9 +3,10 @@ package walk
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-git/go-git/v5"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/go-git/go-git/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
type gitWalker struct {
|
type gitWalker struct {
|
||||||
@ -18,14 +19,12 @@ func (g *gitWalker) Root() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *gitWalker) Walk(ctx context.Context, fn filepath.WalkFunc) error {
|
func (g *gitWalker) Walk(ctx context.Context, fn filepath.WalkFunc) error {
|
||||||
|
|
||||||
idx, err := g.repo.Storer.Index()
|
idx, err := g.repo.Storer.Index()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%w: failed to open index", err)
|
return fmt.Errorf("%w: failed to open index", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range idx.Entries {
|
for _, entry := range idx.Entries {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
@ -38,7 +37,6 @@ func (g *gitWalker) Walk(ctx context.Context, fn filepath.WalkFunc) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
nativeBuildInputs =
|
nativeBuildInputs =
|
||||||
# we need some formatters available for the tests
|
# we need some formatters available for the tests
|
||||||
(import ./formatters.nix pkgs);
|
import ./formatters.nix pkgs;
|
||||||
|
|
||||||
preCheck = ''
|
preCheck = ''
|
||||||
XDG_CACHE_HOME=$(mktemp -d)
|
XDG_CACHE_HOME=$(mktemp -d)
|
||||||
|
Reference in New Issue
Block a user