Skip to content

Commit 4d85411

Browse files
authored
Merge pull request #9429 from mpickering/wip/style-commit
formatting: Add style-commit makefile target
2 parents eaa5245 + 4c884c0 commit 4d85411

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,15 @@ Code Style
155155
---------------
156156
157157
We use automated formatting with Fourmolu to enforce a unified style across the code bases. It is checked in the CI process.
158-
After installing Fourmolu 0.12, you can automatically format the code bases with `make style` at the top level of the project.
159-
You can also use `make style-modified` to only format modified files.
158+
After installing Fourmolu 0.12, there are some makefile targets to help formatting
159+
the code base.
160+
161+
162+
* `make style` - Format the `Cabal`, `Cabal-syntax` and `cabal-install` directories.
163+
* `make style-modified` - Format files modified in the current tree.
164+
* `make style-commit COMMIT=<ref>` - Format files modified between HEAD and the given reference.
165+
166+
160167
161168
Other Conventions
162169
-----------------

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ style-modified: ## Run the code styler on modified files
2525
@git ls-files --modified Cabal Cabal-syntax cabal-install \
2626
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
2727

28+
style-commit: ## Run the code styler on the previous commit
29+
@git diff --name-only HEAD $(COMMIT) Cabal Cabal-syntax cabal-install \
30+
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
31+
2832
# source generation: SPDX
2933

3034
SPDX_LICENSE_HS:=Cabal-syntax/src/Distribution/SPDX/LicenseId.hs

0 commit comments

Comments
 (0)