1#!/bin/sh2#3# SPDX-FileCopyrightText: 2023,2025 Sören Tempel <soeren+git@soeren-tempel.net>4#5# SPDX-License-Identifier: GPL-3.0-only67staged_files() {8 git diff --diff-filter=MA --cached --name-only |9 awk '/..*\.hs/'10}1112if command -v hlint 1>/dev/null && [ ${SKIP_HLINT:-0} -ne 1 ]; then13 files=$(staged_files | \14 xargs -r hlint 2>&1 | \15 awk '/[a-zA-Z.\/][a-zA-Z.\/]*\.hs/')1617 if [ -n "${files}" ]; then18 printf "hlint found the following hints:\n\n" 1>&219 printf "%s\n" "${files}" | sed 's/^/\t/' 1>&220 exit 121 fi22fi2324########################################################################2526if ! command -v ormolu 1>/dev/null; then27 echo "error: ormolu is not installed" 1>&228 exit 129fi3031# TODO: Add an option to ormolu to only print file names.32files=$(staged_files | \33 xargs -r ormolu --mode check 2>&1 | \34 awk '/[a-zA-Z.\/][a-zA-Z.\/]*\.hs/')3536if [ -n "${files}" ]; then37 printf "The following files need to be formated with 'ormolu':\n\n" 1>&238 printf "%s\n" "${files}" | sed 's/^/\t/' 1>&239 exit 140fi4142########################################################################4344if command -v reuse 1>/dev/null; then45 reuse lint --quiet46 if [ $? -ne 0 ]; then47 echo "reuse-lint failed, run it to figure out why." 1>&248 exit 149 fi50else51 echo "WARNING: reuse-lint is not installed!" 1>&252fi