From 11ea556783c0fcc643b9e94558a55c7482c44556 Mon Sep 17 00:00:00 2001 From: Stefan Matting Date: Thu, 24 Nov 2022 11:52:24 +0100 Subject: [PATCH] hlint: fix inplace option, less verbosity on ci (#2865) --- Makefile | 9 ++++----- nix/wire-server.nix | 1 + tools/hlint.sh | 15 +++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 573fa4d6e6a..f048c7f0248 100644 --- a/Makefile +++ b/Makefile @@ -114,6 +114,10 @@ lint-all: formatc hlint-check-all check-local-nix-derivations treefmt hlint-check-all: ./tools/hlint.sh -f all -m check +.PHONY: hlint-inplace-all +hlint-inplace-all: + ./tools/hlint.sh -f all -m inplace + .PHONY: hlint-check-pr hlint-check-pr: ./tools/hlint.sh -f pr -m check @@ -122,11 +126,6 @@ hlint-check-pr: hlint-inplace-pr: ./tools/hlint.sh -f pr -m inplace - -.PHONY: hlint-inplace-all -hlint-inplace-all: - ./tools/hlint.sh -f all -m inplace - .PHONY: hlint-check hlint-check: ./tools/hlint.sh -f changeset -m check diff --git a/nix/wire-server.nix b/nix/wire-server.nix index 194c90fff84..c0c97594e33 100644 --- a/nix/wire-server.nix +++ b/nix/wire-server.nix @@ -300,6 +300,7 @@ let pkgs.helm pkgs.helmfile pkgs.hlint + ( hlib.justStaticExecutables pkgs.haskellPackages.apply-refact ) pkgs.jq pkgs.kubectl pkgs.nixpkgs-fmt diff --git a/tools/hlint.sh b/tools/hlint.sh index 0f16b6e4ae2..9f8ad816d4b 100755 --- a/tools/hlint.sh +++ b/tools/hlint.sh @@ -1,17 +1,16 @@ #!/usr/bin/env bash -usage() { echo "Usage: $0 -f [all, changeset] -m [check, inplace]" 1>&2; exit 1; } +usage() { echo "Usage: $0 -f [all, changeset, pr] -m [check, inplace]" 1>&2; exit 1; } files='' -check=true while getopts ':f:m:k' opt do case $opt in f) f=${OPTARG} if [ "$f" = "all" ]; then - echo "Checking every file…" + files=$(git ls-files | grep \.hs\$) elif [ "$f" = "pr" ]; then files=$(git diff --name-only origin/develop... | grep \.hs\$) elif [ "$f" = "changeset" ]; then @@ -22,9 +21,9 @@ while getopts ':f:m:k' opt ;; m) m=${OPTARG} if [ "$m" = "inplace" ]; then - check=false + : elif [ "$m" = "check" ]; then - check=true + : else usage fi @@ -43,15 +42,15 @@ if [ "${k}" ]; then set -euo pipefail fi -if [ "$f" = "all" ]; then - hlint -g -v +if [ "$f" = "all" ] && [ "$m" = "check" ]; then + hlint -g else count=$(echo "$files" | grep -c -v -e '^[[:space:]]*$') echo "Analysing $count file(s)…" for f in $files do echo "$f" - if [ $check = true ]; then + if [ "$m" = "check" ]; then hlint --no-summary "$f" else hlint --refactor --refactor-options="--inplace" "$f"