stylish-haskell
stylish-haskell copied to clipboard
[feature] stylish-haskell as a pre-commit hook
Hello, i've tried to add pre-commit support for users of stylish-haskell.
You can test it, by
- cloning my fork locally
- create a a new folder e.g.
Exampleoutside thestylish-haskellrepocd Examplegit init- add mail and name to git
- copy
example/Bad.hsfrom the stylish-haskell repo to your folderExample git add Bad.hsgit commit -m "initial commit"pre-commit try-repo your/local/path/to/repo/stylish-haskell/ --all-files- execute it twice, as it will fail the first time
Bad.hsshould be formatted now
EDIT: additional:
- create a
.pre-commit-config.yamlin the repoExamplewith:
repos:
- repo: https://github.com/LucBro/stylish-haskell.git
rev: feature/pre-commit
hooks:
- id: stylish-haskell
- change
Bad.hs - commit your changes
/EDIT
Be aware that the try-repo command of pre-commit works with HEAD of the local stylish-haskell repo, so commit your changes of .pre-commit-hooks.yaml.
The --all-files argument ensures that your Bad.hs is not skipped (and that's the reason why I don't use the command in stylish-haskell/examples, as it would change every .hs file in the repo).
Pre-commit uses cabal to install stylish-haskell. I've tested this with ghc 9.8.2 and
cabal 3.10.3.0.
People should be able to use now stylish-haskell in pre-commit by adding this to their .pre-commit-config.yaml and running pre-commit run --all-files or committing in their haskell project repo.
repos:
- repo: https://github.com/haskell/stylish-haskell.git
# main for the rev: section is possible, but `pre-commit` will complain
rev: release/X.Y.Z
hooks:
- id: stylish-haskell
Thank you Greetings LucBro