From 088f3ee1f49dd85420efe044102376a0a702dd5d Mon Sep 17 00:00:00 2001 From: Brian Skinn Date: Fri, 29 Mar 2024 10:29:48 -0400 Subject: [PATCH] Switch to script-based git status modified check --- .github/workflows/check_formatting.yml | 2 +- scripts/check-dirty-tree.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 scripts/check-dirty-tree.sh diff --git a/.github/workflows/check_formatting.yml b/.github/workflows/check_formatting.yml index 512760d..d769fab 100644 --- a/.github/workflows/check_formatting.yml +++ b/.github/workflows/check_formatting.yml @@ -24,4 +24,4 @@ jobs: run: npm run format - name: Check for dirty working tree - run: git diff | grep -q 'modified' && exit 1 || exit 0 + run: scripts/check-dirty-tree.sh diff --git a/scripts/check-dirty-tree.sh b/scripts/check-dirty-tree.sh new file mode 100644 index 0000000..d1c25eb --- /dev/null +++ b/scripts/check-dirty-tree.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +##################################################################### +# Per https://sharats.me/posts/shell-script-best-practices/ (partial) +set -o errexit +set -o nounset +set -o pipefail + +if [[ "${TRACE-0}" == "1" ]]; then + set -o xtrace +fi +##################################################################### + +git status | grep modified: + +if [ $? = 0 ] +then + exit 1 +fi