Move all config related code into a config package.
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/25
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
Fixes a bug with formatters processing paths out of order.
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/24
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
Allows specifying the order in which formatters are applied.
Very simple for now, adding a `Before` field to the formatted config which allows the user to say that formatter `x` needs to be applied _before_ formatted `y`.
```toml
[formatter.statix]
command = "statix"
includes = ["*.nix"]
before = "deadnix"
[formatter.deadnix]
command = "statix"
includes = ["*.nix"]
```
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/20
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
Introduces a `--walk` flag which can be used to tell `treefmt` how to traverse the directory specified by `--tree-root`.
By default, it will attempt to use `git ls-files`. If this fails, it falls back to using the filesystem.
You can explicitly traverse the filesystem instead of using git by providing `--walk filesystem`.
Close#1
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/19
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
When running against nixpkgs we were stalling. This was due to a long running read tx which was preventing any writes.
This breaks up reading the cache when walking the filesystem into many smaller read txs.
On my laptop I'm now getting the following with the echo sample:
```console
# fresh cache
❯ nix run .# -- -c --config-file ./test/echo.toml --tree-root ../../../github.com/nixos/nixpkgs
38825 files changed in 320.655826ms
# hot cache
❯ nix run .# -- --config-file ./test/echo.toml --tree-root ../../../github.com/nixos/nixpkgs
0 files changed in 252.920853ms%
```
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/18
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
Closes#10
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/15
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
Closes#8
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/16
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
- update `gomod2nix.toml`
- add formatters as `nativeBuildInputs` for nix build
- export a `XDG_CACHE_HOME` for checks
Signed-off-by: Brian McGee <brian@bmcgee.ie>
Tracks the mod time and size of a formatter's executable in bolt.
The cache is busted using the following criteria:
- a new formatter has been configured.
- an existing formatter has changed (mod time or size)
- an existing formatter has been removed from config
Also implemented better resolution of symlinks when determining a formatters executable path.
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/14
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
Stacked on top of #11
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/13
Co-authored-by: zimbatm <zimbatm@zimbatm.com>
Co-committed-by: zimbatm <zimbatm@zimbatm.com>
The package was created before Go introduced their own "errors"
package.
Trade the better juju errors semantic for a smaller dependency tree.
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/11
Co-authored-by: zimbatm <zimbatm@zimbatm.com>
Co-committed-by: zimbatm <zimbatm@zimbatm.com>