Skip to content

Commit 28fc8a8

Browse files
authored
Merge pull request #641 from numtide/fix/stdin-exlude-behaviour
Fix: stdin global exclude behaviour
2 parents 4278a74 + f9b67c5 commit 28fc8a8

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

cmd/root_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,30 @@ func TestDeterministicOrderingInPipeline(t *testing.T) {
22462246
idx++
22472247
}
22482248
}
2249+
2250+
// test with a file that is in global excludes
2251+
// all toml files are globally excluded in the test config
2252+
badToml := `
2253+
foo = "bla"
2254+
bar = [ "bla" ]
2255+
adsfadf;
2256+
`
2257+
os.Stdin = test.TempFile(t, "", "stdin", &badToml)
2258+
2259+
treefmt(t,
2260+
withArgs("--stdin", "treefmt.toml"),
2261+
withNoError(t),
2262+
withStats(t, map[stats.Type]int{
2263+
stats.Traversed: 1,
2264+
stats.Matched: 0,
2265+
stats.Formatted: 0,
2266+
stats.Changed: 0,
2267+
}),
2268+
withStdout(func(out []byte) {
2269+
// it should not have been modified, simply emitted again
2270+
as.Equal(badToml, string(out))
2271+
}),
2272+
)
22492273
}
22502274

22512275
func TestRunInSubdir(t *testing.T) {

format/composite.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func (c *CompositeFormatter) Apply(ctx context.Context, files []*walk.File) erro
6767

6868
// if the file is globally excluded, we do not emit a warning
6969
if globalExclude {
70+
toRelease = append(toRelease, file)
71+
7072
continue
7173
}
7274

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/numtide/treefmt/v2
22

3-
go 1.24.0
3+
go 1.24.1
44

55
require (
66
github.com/BurntSushi/toml v1.5.0

0 commit comments

Comments
 (0)