-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Hi!
Some formatters support an option to assume the filename when content is passed through stdin (clang-format's --assume-filename, ruff's --stdin-filename). Based on that filename they may act as if the user has passed an actual file.
I'm particularly interested in include/exclude config settings.
Currently, given this config
match_type: doublestar
exclude: ["**/skip.yaml"]I get the following output when provide the file path
$ ./yamlfmt -v -debug all -conf .yamlfmt skip.yaml
[DEBUG]: Using config path .yamlfmt from -conf flag
[DEBUG]: using doublestar path matching. include patterns: [skip.yaml]
[DEBUG]: trying pattern: skip.yaml
[DEBUG]: pattern skip.yaml matches: [skip.yaml]
[DEBUG]: calculating excludes for skip.yaml
[DEBUG]: pattern **/skip.yaml matched, excluding
[DEBUG]: paths to format: []
[DEBUG]: The following files were modified:
The following files were modified:
When passed to stdin it's being modified regardless which is expected
$ cat skip.yaml | ./yamlfmt -v -debug all -conf .yamlfmt -
[DEBUG]: Using config path .yamlfmt from -conf flag
[DEBUG]: using doublestar path matching. include patterns: [-]
[DEBUG]: trying pattern: -
[DEBUG]: pattern - matches: []
[DEBUG]: paths to format: []
a: 1
With -stdin_filename skip.yaml modification wouldn't have happened.
$ cat skip.yaml | ./yamlfmt -v -debug all -conf .yamlfmt -stdin_filename skip.yaml -
[DEBUG]: Using config path .yamlfmt from -conf flag
[DEBUG]: using doublestar path matching. include patterns: [skip.yaml]
[DEBUG]: trying pattern: skip.yaml
[DEBUG]: pattern skip.yaml matches: [skip.yaml]
[DEBUG]: calculating excludes for skip.yaml
[DEBUG]: pattern **/skip.yaml matched, excluding
[DEBUG]: paths to format: []
[DEBUG]: The following files were modified:
The following files were modified:
yamlfmt version
$ ./yamlfmt --version
yamlfmt 0.20.0 (42486ac)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels