-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from hhefesto/pre-commit-hook
Pre commit hook
- Loading branch information
Showing
2 changed files
with
47 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Formatting:" | ||
# Formatting | ||
nix develop -c stylish-haskell -irv . | ||
output=$(git diff) | ||
if [ "$output" = "" ]; then | ||
echo "Success! No formatting suggestions applied." | ||
else | ||
echo "These stylish-haskell formatting changes will be made for your commit:" | ||
echo "$output" | ||
fi | ||
echo "Finished formatting" | ||
|
||
# Linting | ||
# TODO: The --refactor flag does not work even after adding `apply-refactor` to the devShell | ||
echo "Linting:" | ||
output=$(nix develop -c hlint . --no-exit-code) | ||
if [ "$output" = "No hints" ]; then | ||
echo "Success! No Hlint suggestions." | ||
else | ||
echo "Failure: Hlint has some suggestions for your commit" | ||
echo "$output" | ||
echo "Please fix or add an exception to the .hlint.yaml file" | ||
exit 1 | ||
fi | ||
echo "Finished linting" |