Commit Graph

17 Commits

Author SHA1 Message Date
Brian McGee
42decbfafb
fix: --no-cache
Separates out the logic for detecting changes from the logic for updating the cache, fixing the case where both `--fail-on-change` and `--no-cache` are enabled.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
Co-authored-by: Jonas Chevalier <zimbatm@zimbatm.com>
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-07-05 21:52:34 +01:00
Brian McGee
30d30b54f0
Merge pull request #321 from numtide/softer-cancel
Softer cancel
2024-06-15 11:28:48 +01:00
zimbatm
c68261e979 fix: stop hard-killing formatters
Give the processes some chance to clean after themselves.

Fixes https://github.com/numtide/treefmt/issues/316#issuecomment-2160628891
2024-06-14 14:11:23 +02:00
zimbatm
6d6a71a3ca chore: do a golangci-lint pass
golangci-lint doesn't follow the treefmt spec so it can't be integrated
with treefmt unfortunately.
2024-06-14 12:32:57 +02:00
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
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
Brian McGee
3c264c623e
feat: log out the formatter command being applied at debug level
Closes #292

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-17 10:39:15 +01:00
Brian McGee
2b94480461
fix: use resolved executable when applying a formatter
We were going to the trouble of resolving the command to an executable via the PATH but were not using that executable when executing the formatting command.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-17 09:49:41 +01: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
ed10f976f8
fix: fmt.Errorf formats
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-02 11:40:49 +01:00
Brian McGee
2eaf999a0e
feat: refactor some config init logic into config package
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-02 10:56:32 +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
40b76b74a0
feat: ensure deterministic application of formatters
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-26 10:33:29 +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
c71d69051a
feat: have each formatter filter paths again if part of a pipeline
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-25 09:17:51 +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
d4ab015bc6
chore: remove internal directory
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-02-15 13:59:55 +00:00