-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add flag to
dune fmt
to disable promoting (#8289)
Sometimes you just want to see the diff without applying it. Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Add a `--preview` flag to `dune fmt` which causes it to print out the changes | ||
it would make without applying them (#8289, @gridbugs) |
34 changes: 34 additions & 0 deletions
34
test/blackbox-tests/test-cases/formatting/fmt-no-promote.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
$ cat > dune-project << EOF | ||
> (lang dune 3.0) | ||
> EOF | ||
|
||
Make a dune file that should be formatted. | ||
$ cat > dune << EOF | ||
> (rule (write-file a b)) | ||
> EOF | ||
|
||
Run `dune fmt --preview` twice to test it is idempotent. In a terminal these | ||
commands would also print the diff of what would be changed. | ||
$ dune fmt --preview | ||
File "dune", line 1, characters 0-0: | ||
Error: Files _build/default/dune and _build/default/.formatted/dune differ. | ||
[1] | ||
$ dune fmt --preview | ||
File "dune", line 1, characters 0-0: | ||
Error: Files _build/default/dune and _build/default/.formatted/dune differ. | ||
[1] | ||
|
||
Show the formatted file from _build. | ||
$ cat _build/default/.formatted/dune | ||
(rule | ||
(write-file a b)) | ||
|
||
Actually format the file | ||
$ dune fmt | ||
File "dune", line 1, characters 0-0: | ||
Error: Files _build/default/dune and _build/default/.formatted/dune differ. | ||
Promoting _build/default/.formatted/dune to dune. | ||
[1] | ||
|
||
Now the output of `dune fmt --preview is empty`. | ||
$ dune fmt --preview |