You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's what happens if I'm in some project and use a relative path to ask treefmt to format a file outside of the project:
proj/ $ treefmt --no-cache ../out-of-tree.py
traversed 0 files
emitted 0 files for processing
formatted 0 files (0 changed) in 2ms
Error: failed to close reader: path '/tmp/tmp.V5f56DPrFE/out-of-tree.py' is outside of the root '/tmp/tmp.V5f56DPrFE/proj'
This is different than nice "not found within the tree root" error message we normally get:
proj/ $ treefmt --no-cache /out-of-tree.py
Error: path /out-of-tree.py not found within the tree root /tmp/tmp.V5f56DPrFE/proj
To Reproduce
Here's the setup for the above commands:
$ cd "$(mktemp -d)"
$ touch out-of-tree.py
$ mkdir proj
$ cd proj
$ git init
$ nix shell github:numtide/treefmt nixpkgs#black
$ treefmt --version
treefmt v659aa0f
$ cat treefmt.toml # create this file
[formatter.python]
command = "black"
includes = ["*.py"]
Expected behavior
I acknowledge this is a pretty nitty cosmetic issue. That said, I would expect treefmt to give the same error message for files outside of the tree root.
This fixes a few issues with both relative and absolute paths:
- Previously, treefmt refused to format any files passed as absolute
paths, regardless of if they were in tree or not: numtide#442
- Previously, treefmt would treat relative paths as relative to the
project root, which is not ideal if you're in a subdirectory and you
just want to format the file you're right next to: numtide#443
- There was even a test asserting this behavior. I changed it to
reflect the updated behavior.
- treefmt's handling of paths outside of the project root was a bit
inconsistent: numtide#444
This fixes a few issues with both relative and absolute paths:
- Previously, treefmt refused to format any files passed as absolute
paths, regardless of if they were in tree or not: numtide#442
- Previously, treefmt would treat relative paths as relative to the
project root, which is not ideal if you're in a subdirectory and you
just want to format the file you're right next to: numtide#443
- There was even a test asserting this behavior. I changed it to
reflect the updated behavior.
- treefmt's handling of paths outside of the project root was a bit
inconsistent: numtide#444
Here's what happens if I'm in some project and use a relative path to ask treefmt to format a file outside of the project:
This is different than nice "not found within the tree root" error message we normally get:
To Reproduce
Here's the setup for the above commands:
Expected behavior
I acknowledge this is a pretty nitty cosmetic issue. That said, I would expect treefmt to give the same error message for files outside of the tree root.
System information
See above. I'm using 659aa0f.
The text was updated successfully, but these errors were encountered: