Commit Graph

230 Commits

Author SHA1 Message Date
Brian McGee
30d30b54f0
Merge pull request #321 from numtide/softer-cancel
Softer cancel
2024-06-15 11:28:48 +01:00
zimbatm
e29107d3ee fix: only cancel formatters on background errors
If any of the formatting action returns an error, keep going to surface
as many errors as possible.

If the user hits Ctrl-C then terminate everything.
2024-06-15 11:57:57 +02:00
Brian McGee
4e8daacca3
Merge pull request #320 from numtide/golangci-lint
chore: do a golangci-lint pass
2024-06-14 14:20:32 +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
Jonas Chevalier
6b591255b1
test: add tests for glob matching (#319)
This helps demonstrate how our globbing works.
2024-06-14 12:57:51 +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
mergify[bot]
251012657a
Merge pull request #318 from numtide/feat/improve-unmatched
feat: improve unmatched logic
2024-06-14 09:36:20 +00: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
mergify[bot]
2ca613901d
Merge pull request #315 from numtide/dependabot/github_actions/goreleaser/goreleaser-action-6
chore(deps): bump goreleaser/goreleaser-action from 5 to 6
2024-06-11 07:56:04 +00:00
dependabot[bot]
57b907d99d
chore(deps): bump goreleaser/goreleaser-action from 5 to 6
Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 5 to 6.
- [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
- [Commits](https://github.com/goreleaser/goreleaser-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: goreleaser/goreleaser-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-10 17:55:16 +00:00
mergify[bot]
51640c85d3
Merge pull request #314 from katexochen/cli-no-global-state
cli: remove global state, init function usage
2024-06-07 08:16:03 +00:00
Paul Meyer
c07305e6b0 cli: remove global state, init function usage
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2024-06-06 20:28:37 +02:00
Brian McGee
ab2b373094
Merge pull request #313 from numtide/fix/stdin
fix: --stdin flag
2024-06-05 15:13:52 +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
mergify[bot]
2454542a36
Merge pull request #309 from numtide/find-tree-root
cli: search for the tree root by default
2024-05-30 18:09:47 +00:00
mergify[bot]
ed2960d9b2
Merge branch 'main' into find-tree-root 2024-05-30 18:09:15 +00:00
zimbatm
7f4697fc49 simplify logic 2024-05-30 19:56:26 +02:00
zimbatm
bc89625cb9 fix TreeRootFile type
kong resolves path types to absolute paths
2024-05-30 19:44:17 +02:00
zimbatm
bc928bdf2b fixup! Update cli/cli.go 2024-05-30 19:31:31 +02:00
mergify[bot]
3f44ec4542
Merge pull request #307 from numtide/docs-pass
docs: some small changes
2024-05-30 17:23:06 +00:00
Jonas Chevalier
e368d3ee80
Update docs/configure.md
Co-authored-by: Brian McGee <brian@bmcgee.ie>
2024-05-30 19:19:57 +02:00
Jonas Chevalier
f9a464ce5e
Update docs/configure.md
Co-authored-by: Brian McGee <brian@bmcgee.ie>
2024-05-30 19:19:51 +02:00
zimbatm
0511e9acf1 fixes https://github.com/numtide/treefmt/pull/309#discussion_r1620949820 2024-05-30 19:17:57 +02:00
Jonas Chevalier
088479eb27
Update cli/cli.go
Co-authored-by: Brian McGee <brian@bmcgee.ie>
2024-05-30 19:10:07 +02:00
zimbatm
bd32d36a33 cli: search for the tree root by default
Restore the treefmt 1.x behaviour where it would search for the tree
root by recursively searching for the treefmt.toml file up the
filesystem, starting from the current directory.

The `--tree-root-file` option will be useful to remove this bash wrapper: 2fba33a182/module-options.nix (L116-L135)

Fixes #308
2024-05-30 15:46:00 +02:00
zimbatm
2575f2e143 docs: put motivation first
Explain why this project exists, before diving into it
2024-05-30 14:26:38 +02:00
zimbatm
7792121c95 docs: link to treefmt-nix instead of duplicating the examples 2024-05-30 14:26:38 +02:00
zimbatm
fccb46367c docs: focus on the default experience in the quickstart
Most of the time you don't need the extra running options.
2024-05-30 14:26:38 +02:00
zimbatm
93955bbc3c docs: document the global format 2024-05-30 14:26:38 +02:00
Brian McGee
022398399f
fixup! feat: configure goreleaser to mark releases as pre-release (#305)
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-29 15:25:07 +01:00
Jonas Chevalier
7afdc7a3ee
Merge pull request #303 from numtide/feat/show-unmatched
--on-unwatched
2024-05-29 12:05:21 +02:00
Brian McGee
bbe50fbe75
doc: refine --on-unmatched usage
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-29 10:32:02 +01:00
Brian McGee
1b517c6502
feat: add --on-unmatched
By default, if a path does not match any formatter a log message at WARN level will be emitted. A user can change this by providing the `--on-unmatched` or `-u` flag and specifying a log level `debug,info,warn,error,fatal`.

If fatal, the process will exit with an error on the first unmatched path encountered.

Closes #302

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-29 10:32:02 +01:00
Brian McGee
6cf9524aa7
fix: cleanup cwd change in deterministic pipeline test 2024-05-29 10:32:02 +01:00
Brian McGee
6c7fd57b5c
fix: remove config2 alias in format_test.go
It's unnecessary.
2024-05-29 10:32:02 +01:00
Brian McGee
53b0dc5536
feat: configure goreleaser to mark releases as pre-release (#305)
This is to prevent noise until we have a stable 2.x

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-29 09:23:54 +02:00
Brian McGee
ff957c5f1a
fix: restrict github pages publication to published releases (#304)
We currently publish an update when we merge to `main`. This means new functionality that is not yet released is being talked about on the docs site.

This restricts deploying to github pages to only published releases.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-29 09:23:34 +02:00
mergify[bot]
06f15f4237
Merge pull request #301 from numtide/feat/better-concurrency-model
feat: simplify pipeline model
2024-05-26 20:11:48 +00: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
mergify[bot]
6ce3d27519
Merge pull request #300 from numtide/dependabot/github_actions/cachix/install-nix-action-27
chore(deps): bump cachix/install-nix-action from 26 to 27
2024-05-21 10:59:39 +00:00
dependabot[bot]
af5d2eb375
chore(deps): bump cachix/install-nix-action from 26 to 27
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 26 to 27.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v26...V27)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-21 10:58:40 +00:00
Brian McGee
533f4e2f0e
Merge pull request #299 from numtide/dependabot/github_actions/cachix/cachix-action-15
chore(deps): bump cachix/cachix-action from 14 to 15
2024-05-21 11:58:04 +01:00
dependabot[bot]
105536b24f
chore(deps): bump cachix/cachix-action from 14 to 15
Bumps [cachix/cachix-action](https://github.com/cachix/cachix-action) from 14 to 15.
- [Release notes](https://github.com/cachix/cachix-action/releases)
- [Commits](https://github.com/cachix/cachix-action/compare/v14...v15)

---
updated-dependencies:
- dependency-name: cachix/cachix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-20 17:38:26 +00:00
Jonas Chevalier
a969e31956
docs: clearer landing page (#298)
I tried to make it clearer for fresh eyes what this project is about
2024-05-18 09:45:38 +02:00
mergify[bot]
a20db207db
Merge pull request #297 from numtide/feat/error-when-path-matches-multiple-formatters
Error out when a path matches multiple formatters
2024-05-17 11:06:38 +00:00
Brian McGee
06e41453ec
feat: error out when a path matches multiple formatters
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-17 11:55:31 +01:00
mergify[bot]
4199706ddd
Merge pull request #296 from numtide/feat/switch-to-treefmt-nix
feat: switch back to numtide/treefmt-nix
2024-05-17 10:26:58 +00:00
Brian McGee
affbb99ef9
feat: switch back to numtide/treefmt-nix
It now supports freeform type for settings allowing us to pass through pipeline options.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-17 11:19:48 +01:00