quebex

A software analysis framework built around the QBE intermediate language

git clone https://git.8pit.net/quebex.git

 1#!/bin/sh
 2#
 3# SPDX-FileCopyrightText: 2023,2025 Sören Tempel <soeren+git@soeren-tempel.net>
 4#
 5# SPDX-License-Identifier: GPL-3.0-only
 6
 7if ! command -v ormolu 1>/dev/null; then
 8	echo "error: ormolu is not installed" 1>&2
 9	exit 1
10fi
11
12# TODO: Add an option to ormolu to only print file names.
13files=$(git diff --diff-filter=MA --cached --name-only | \
14	awk '/..*\.hs/' | \
15	xargs -r ormolu --mode check 2>&1 | \
16	awk '/[a-zA-Z.\/][a-zA-Z.\/]*\.hs/')
17
18if [ -n "${files}" ]; then
19	printf "The following files need to be formated with 'ormolu':\n\n" 1>&2
20	printf "%s\n" "${files}" | sed 's/^/\t/' 1>&2
21	exit 1
22fi
23
24########################################################################
25
26if command -v reuse 1>/dev/null; then
27	reuse lint --quiet
28	if [ $? -ne 0 ]; then
29		echo "reuse-lint failed, run it to figure out why." 1>&2
30		exit 1
31	fi
32else
33	echo "WARNING: reuse-lint is not installed!" 1>&2
34fi