Skip to content

Commit

Permalink
Add fix-stylish-haskell script (#444)
Browse files Browse the repository at this point in the history
slightly adapted from plutus repo.

---------

Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
  • Loading branch information
3 people authored May 16, 2023
1 parent 18d9bc9 commit a476b84
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ let
inherit (import sources.cardano-repo-tool {inherit system;}) cardano-repo-tool;
stack-cabal-sync-shell = pkgsDefault.callPackage ./pkgs/stack-cabal-sync-shell.nix { inherit cardano-repo-tool; };
supervisord = pkgsDefault.callPackage ./supervisord {};
fixStylishHaskell = pkgsDefault.callPackage ./tests/fix-stylish-haskell.nix {};

# Check scripts
check-hydra = __trace "check-hydra is deprecated. Please use hydraEvalErrors" pkgsDefault.callPackage ./ci/check-hydra.nix {};
Expand Down Expand Up @@ -189,7 +190,8 @@ let
checkCabalProject
hydraEvalErrors
checkRepoTagsOnMasterBranches
checkStackProject;
checkStackProject
fixStylishHaskell;
release-lib = ./lib/release-lib.nix;
};
in self
17 changes: 17 additions & 0 deletions tests/fix-stylish-haskell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ writeScriptBin, git, fd, stylish-haskell }:

writeScriptBin "fix-stylish-haskell" ''
${git}/bin/git diff > pre-stylish.diff
${fd}/bin/fd --extension hs "$@" \
--exec ${stylish-haskell}/bin/stylish-haskell -i {}
${git}/bin/git diff > post-stylish.diff
diff pre-stylish.diff post-stylish.diff > /dev/null
if [ $? != 0 ]
then
echo "Changes by stylish have been made. Please commit them."
else
echo "No stylish changes were made."
fi
rm pre-stylish.diff post-stylish.diff
exit
''
2 changes: 1 addition & 1 deletion tests/stylish-haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runCommand "stylish-check" {
diff -ur orig stylish > $out/stylish.diff
echo "file none $out/stylish.diff" > $out/nix-support/hydra-build-products
echo "*** Stylish-haskell found changes that need addressed first"
echo "*** Please run \`nix-shell -A fixStylishHaskell\` and commit changes"
echo "*** Please run `$(nix-build ./nix -A iohkNix.fixStylishHaskell)/bin/fix-stylish-haskell --exclude '*/dist/*' --exclude '*/docs/*'` and commit changes"
echo "*** or apply the diff generated by hydra if you don't have nix."
exit $EXIT_CODE
else
Expand Down

0 comments on commit a476b84

Please sign in to comment.