On 07/22/2016 02:34 AM, Bryan Richter wrote:
> Just wanted to share a git hook I'm using to automatically apply hlint
> to Haskell files that I'm commiting.
> 
> First all I'm using the existing pre-commit example that git provides
> (.git/hooks/pre-commit.sample). Just copy that file to
> .git/hooks/pre-commit and `chmod 755` it.
> 
> Then I chained an hlint check to the whitespace check:
> 
> --- .git/hooks/pre-commit.sample      2016-07-14 09:56:25.509776550 +0300
> +++ .git/hooks/pre-commit     2016-07-22 12:23:12.997344972 +0300
> @@ -46,4 +46,11 @@
>  fi
>  
>  # If there are whitespace errors, print the offending file names and fail.
> -exec git diff-index --check --cached $against --
> +if git diff-index --check --cached $against --
> +then
> +    # Otherwise, if Haskell files have changed, run hlint on them.
> +    changedHaskell=$(git diff-index --diff-filter=ACMR --numstat --cached 
> $against -- '*.hs' | cut -f3)
> +    exec ${changedHaskell:+hlint -XQuasiQuotes $changedHaskell}
> +else
> +    exit 1
> +fi
> 
> Honestly I bet there's a nicer way to get the list of changed Haskell
> files, but git is weird.
> 
> 
> 

I have vim set up to automatically run hlint whenever I save a file (via
syntastic I believe), but I don't know how to make that use the
-XQausiQuotes argument.


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Dev mailing list
Dev@lists.snowdrift.coop
https://lists.snowdrift.coop/mailman/listinfo/dev

Reply via email to