Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] stylish-haskell as a pre-commit hook #481

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LucBro
Copy link

@LucBro LucBro commented May 31, 2024

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. Example outside the stylish-haskell repo
    • cd Example
    • git init
    • add mail and name to git
    • copy example/Bad.hs from the stylish-haskell repo to your folder Example
    • git add Bad.hs
    • git 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.hs should be formatted now

EDIT:
additional:

  • create a .pre-commit-config.yaml in the repo Example with:
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant