Jonas Chevalier
f7e2aa079e
expand includes and excludes ( #86 )
...
If includes or excludes include a / we consider them to be paths and
expand them.
2021-03-02 17:26:50 +01:00
Andika Demas Riyandi
164a74a9e3
fix hierarchy of the books ( #80 )
2021-03-02 12:29:31 +01:00
Basile Henry
3d64d582f9
Time phases individually ( #83 )
...
* Time phases individually
* More consistent timing precision
2021-03-02 12:21:41 +01:00
Basile Henry
38201beb21
Update Cargo.toml
2021-03-02 11:00:28 +01:00
zimbatm
77034594a6
Cargo.toml: add basile
2021-03-02 10:15:34 +01:00
zimbatm
904eeff10b
nix: better stable nix support
...
Stable nix users shouldn't have to deal with that long attribute name
when they want to install treefmt. Just `nix-build` the project root and
you're good to go.
2021-03-01 18:26:26 +01:00
Jonas Chevalier
8a2c84e786
license: fix attribution ( #72 )
2021-03-01 17:47:38 +01:00
zimbatm
96058b3eb5
formatter -> processed
2021-03-01 11:38:23 +01:00
Jonas Chevalier
a5f76ebc57
cli: add --fail-on-change ( #75 )
...
Make the CI scenario a bit easier to integrate.
2021-02-27 16:15:01 +00:00
Jonas Chevalier
6e560d5f09
cli: format the whole tree by default ( #74 )
...
Instead of formatting the current directory, format the whole tree if no
paths are given.
Use `treefmt .` to format the current folder.
That way it's less likely that some files will not be re-formatted, even
if the user is working in a sub-folder.
2021-02-27 15:07:09 +00:00
Jonas Chevalier
69cdd005b5
add --tree-root ( #73 )
...
Allow to override the location of the tree
2021-02-27 14:15:01 +00:00
zimbatm
e0a56fc9d0
README: fix wording a bit
2021-02-27 13:32:17 +01:00
zimbatm
e184fdc0d7
remove outdated TODO
...
As per Twitter code review:
https://twitter.com/pesterhazy/status/1365615973865291781?s=20
2021-02-27 12:34:55 +01:00
Jonas Chevalier
e9cce9a84d
Merge pull request #71 from numtide/parallel-format
...
Parallel format
2021-02-27 11:20:59 +00:00
zimbatm
9fcdd5619f
engine: format in parallel
...
Re-introduce the magic by @basile-henri
before: 1.374864208s
after: 637.515185ms
2021-02-27 11:43:45 +01:00
zimbatm
538fd56c57
engine: prepare for parallelism
2021-02-27 11:35:19 +01:00
zimbatm
2be1498294
justify all unwraps
2021-02-27 11:13:23 +01:00
zimbatm
dd0d6c87f2
engine: improve the elapsed times display
2021-02-27 10:52:44 +01:00
zimbatm
6b72db4087
docs: add list of known formatters
2021-02-26 22:02:16 +01:00
Jonas Chevalier
f6880f1fa2
address clippy warnings ( #70 )
2021-02-25 21:45:40 +00:00
Jonas Chevalier
7408248239
ci: add more tests outside of Nix ( #69 )
...
Nix is too pure and won't catch other OS-es divergences.
2021-02-25 22:23:18 +01:00
zimbatm
3e8eefc096
cli: implement the --clear-cache option
...
Fixes #16
2021-02-25 21:35:55 +01:00
zimbatm
72268ac588
cli: transform --init as a flag
...
It makes the --help usage more readable
2021-02-25 21:31:44 +01:00
Jonas Chevalier
e05a1e49bd
Merge pull request #68 from numtide/refactor-xxx
...
re-implement the core logic
2021-02-25 18:31:04 +00:00
zimbatm
c9bc5c63c9
only run formatters if there are files to format
...
Add more debugging. Take the baseline from ~500millis to ~60millis.
2021-02-25 19:21:33 +01:00
zimbatm
fd7d6e2396
fix clippy warnings
2021-02-25 19:20:48 +01:00
zimbatm
c9115ddcdd
benches: remove dead code
2021-02-25 19:20:04 +01:00
zimbatm
1396279664
config: don't resolve the formatter
...
This is already handled by the formatter himself
2021-02-25 18:27:39 +01:00
zimbatm
09d1d3527b
engine: add small report
2021-02-25 18:23:17 +01:00
zimbatm
a1c016e25b
re-implement the eval cache
2021-02-25 17:52:17 +01:00
zimbatm
4991a97d37
use directories
...
Use OS-specific locations for the cache directory to make treefmt
cross-platform.
2021-02-25 14:48:13 +01:00
zimbatm
732439aff6
re-implement the core logic
...
I had to remove the evaluation cache and parallel formatting for now in
order to make this manageable.
* Load the config
* Prepare for filesystem traversal
* Match each path against the formatters and collect the ones that
match. Get the mtime from the traversal entry to avoid additional
syscalls.
* Now that we have a map from formatter to paths, run each formatter
against its list. Collect a list of new mtimes.
* Finally display the list of files that have changed.
2021-02-25 14:48:13 +01:00
Jonas Chevalier
08681ac464
implement our own expand_path ( #67 )
...
path-absolutize's absolutize_virtually was actually failing if path is
already absolute and not under the reference directory. But we just want
to expand the path and make sure it's absolute and clean.
2021-02-25 11:14:56 +01:00
Jonas Chevalier
8cc26e58ed
Merge pull request #66 from numtide/cargo-cleanup
...
Cargo cleanup
2021-02-23 10:50:58 +00:00
zimbatm
0748cd21af
Cargo: remove unused either
2021-02-23 09:13:26 +01:00
zimbatm
7881fdc210
Cargo: replace hex with stdlib fmt
2021-02-23 09:11:00 +01:00
zimbatm
c1bb7d073c
Cargo: remove unused glob package
2021-02-23 09:08:30 +01:00
Jonas Chevalier
7a95af7f95
Merge pull request #65 from numtide/config-simplifications
...
more config simplification
2021-02-22 16:11:43 +00:00
zimbatm
95b85ffcec
cache: Mtime newtype
...
Expose even further where the cache implementation is leaking
2021-02-22 16:32:24 +01:00
zimbatm
33226de5f8
fixup
2021-02-22 16:08:20 +01:00
Jonas Chevalier
f6848f01f5
Update src/command/mod.rs
...
Co-authored-by: Basile Henry <bjm.henry@gmail.com>
2021-02-22 15:04:18 +00:00
zimbatm
77f45d6cd5
address clippy warnings
2021-02-22 15:57:50 +01:00
zimbatm
ec77b3f710
cache: add get_mtime utility
...
Unify how we get back mtimes from files. Ideally, all the callers to
get_mtime would be part of the cache and not split out like they
currently are.
2021-02-22 15:53:33 +01:00
zimbatm
bde7493591
cache: soft failure on manifest loading issue
...
If the manifest couldn't be loaded it's probably that the file format
has changed. Ignore the error and continue.
2021-02-22 15:42:11 +01:00
zimbatm
3bb40df07f
cache: rename mtimes to mtime
...
There is only a single value attached to it.
2021-02-22 15:18:53 +01:00
zimbatm
449d466e96
config: resolve the formatter command early
...
Get the absolute path of the formatter command during config load. If
it could not be resolved, warn the user and drop that formatter from
the list of commands that will get evaluated.
2021-02-22 15:11:41 +01:00
zimbatm
1f5c7c30f1
Cargo: optimize path-absolutize
...
Now that all the uses of std::env::set_current_dir have been removed, we
can add a bit of caching in that crate.
2021-02-22 14:09:34 +01:00
zimbatm
09638af104
config: resolve all the work_dir to absolute paths
...
By moving the resolution to parse time, it simplifies the core of the
algorithm.
2021-02-22 13:29:06 +01:00
zimbatm
09d40f4539
cli: make sure the work_dir is absolute
...
Since we do a lot of path manipulation, with commands changing
directories and whatnot. It's probably easier to work with only absolute
paths.
If we can guarantee that, the rest will become easier.
2021-02-22 13:01:05 +01:00
zimbatm
7db38296d9
change the meaning of the -C option
...
Use the same semantic as `git` where `-C` is used to switch working
directories.
Simplify the startup sequence and responsibilities between the CLI and
the engine. DRY "treefmt.toml" to config::FILENAME.
2021-02-22 12:30:39 +01:00