Commit Graph

17 Commits

Author SHA1 Message Date
Brian McGee
56d8561125
feat: improve unmatched logic
Separates global excludes processing from `Formatter.Wants`. This removes redundant processing of global excludes in each `Formatter.Wants` call.

If a file has been globally excluded, we do not emit an `on-unmatched` log message. This should help reduce as reported in #317.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-06-14 10:31:47 +01:00
Brian McGee
089eb171a0
fix: --stdin flag
This was incorrectly ported from Rust to Go.

When `--stdin` is provided, `treefmt` copy the `stdin` into a temporary file, using the first path argument as the filename. This allows the user to control which formatters will match this temp file based on their `treefmt` config.

After the formatters have been applied, the contents of this temporary file are then printed to stdout and the temp file is removed.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-06-05 15:06:10 +01:00
Brian McGee
4f086c204e
Revert "fix: --stdin flag"
This reverts commit 9934a5764d.
2024-06-04 17:05:56 +01:00
Brian McGee
9934a5764d
fix: --stdin flag
This was incorrectly ported from Rust to Go.

When provided, `treefmt` will take the contents of stdin and place them into the file provided with the `--stdin` flag, then format it according to the configured formatters.

If the file doesn't exist it is created. If it exists, it is first truncated and then populated with stdin.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-06-03 17:07:34 +01:00
Brian McGee
ce14ee828f
feat: simplify pipeline model
For each path we determine the list of formatters that are interested in formatting it. From there, we sort
the list of formatters first by priority (lower value, higher priority) and then by name (lexicographically).

With this information we create a batch key which is based on the unique sequence of formatters. When enough paths with the same sequence is ready we apply them in order to each formatter.

By default, with no special configuration, this model guarantees that a given path will only be processed by one formatter at a time.

If a user wishes to influence the order in which formatters are applied they can use the priority field.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-26 16:52:04 +01:00
dependabot[bot]
039888b250
chore(deps): bump flask from 0.12.1 to 2.2.5 in /test/examples/python
Bumps [flask](https://github.com/pallets/flask) from 0.12.1 to 2.2.5.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/0.12.1...2.2.5)

---
updated-dependencies:
- dependency-name: flask
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-13 08:09:09 +00:00
Brian McGee
92321c8737
feat: improve specifying formatters test
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-10 11:43:28 +01:00
Brian McGee
5a5c1ea03e
fix: record cache entries for files that don't match formatters
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-02 08:58:02 +01:00
Brian McGee
fcce518d5e
feat: various perf improvements
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-25 12:16:04 +01:00
Brian McGee
6ae0e4f8e4
feat: add pipeline priority field
Allows for fine-grained control of execution order.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-25 09:38:41 +01:00
Brian McGee
8af5b3c076
feat: introduce concept of pipelines for better concurrency
Replaces the `Before` config option with an optional `Pipeline` key.

This is used to group formatters together in the order in which they are specified within the config file.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-24 16:33:22 +01:00
Brian McGee
2b49923bf7
feat: add an example of 'before'
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-02-15 14:17:16 +00:00
Brian McGee
d4ab015bc6
chore: remove internal directory
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-02-15 13:59:55 +00:00
Brian McGee
4c45d2aa7e feat: allow missing formatters (#6)
Closes #3

Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/6
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
2023-12-23 15:00:39 +00:00
Brian McGee
298e5ac217
feat: change module root to git.numtide.com 2023-12-23 13:39:16 +00:00
Brian McGee
12452b01b6
feat: align example treefmt config with flake treefmt config
Prevent unnecessary reformatting
2023-12-23 13:06:50 +00:00
Brian McGee
6904097171
feat: initial import 2023-12-23 12:50:51 +00:00