diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 373f9ffe0ef..89d6d1753db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,6 +145,7 @@ Code Style We use automated formatting with Fourmolu to enforce a unified style across the code bases. It is checked in the CI process. After installing Fourmolu ≥ 0.12, you can automatically format the code bases with `make style` at the top level of the project. +You can also use `make style-modified` to only format modified files. Other Conventions ----------------- diff --git a/Makefile b/Makefile index 91ade431fa7..19e9a4ac63b 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,15 @@ style: ## Run the code styler ! -path Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs \ | xargs -P $(PROCS) -I {} fourmolu -q -i {} +style-modified: ## Run the code styler on modified files + @git ls-files --modified Cabal Cabal-syntax cabal-install \ + -X Cabal-syntax/src/Distribution/Fields/Lexer.hs \ + -X Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs \ + -X Cabal-syntax/src/Distribution/SPDX/LicenseId.hs \ + -X Cabal/src/Distribution/Simple/Build/Macros/Z.hs \ + -X Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs \ + | grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {} + # source generation: Lexer LEXER_HS:=Cabal-syntax/src/Distribution/Fields/Lexer.hs