From ff7585295fd291e523eb1f4eb798a968be014cbc Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Wed, 27 Nov 2024 19:49:50 -0500 Subject: [PATCH] Ask dhall lint to show its cards `dhall lint --check` appears to be inconsistently opinionated. Instead, get a baseline, ask `dhall lint` to rewrite files, and then compare the state of the world before/after, and finally compare the files that dhall lint potentially rewrote. --- check.sh | 5 ++--- dhall-linter | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100755 dhall-linter diff --git a/check.sh b/check.sh index 2e9f030..bca9027 100755 --- a/check.sh +++ b/check.sh @@ -36,12 +36,11 @@ fi if [ -n "$LINT" ]; then echo "::group::lint" - if cat "$LIST" | xargs -0 dhall lint --check; then - echo '::notice::Linting passed.' - else + if ! cat "$LIST" | xargs -0 "$GITHUB_ACTION_PATH/dhall-linter"; then echo '::error::Linting failed. Use `dhall lint` locally to fix the errors.' exit 1 fi + echo '::notice::Linting passed.' echo "::endgroup::" fi diff --git a/dhall-linter b/dhall-linter new file mode 100755 index 0000000..f1559a6 --- /dev/null +++ b/dhall-linter @@ -0,0 +1,9 @@ +#!/bin/sh +baseline=$(mktemp) +git status > "$baseline" || true +dhall lint "$@" +updated=$(mktemp) +git status > "$updated" || true +diff -u "$baseline" "$updated" || true +echo +git diff --exit-code -- "$@"